从命令行在 Bitbucket 上创建 Pull Request

Create a Pull Request on Bitbucket from the command line

是否有 git 命令在推送 Branch 时直接在 Bitbucket 上创建 Pull Request

或直接从命令行或 PHP

在 Bitbucket 上创建 Pull Request 的任何其他方式

您可以使用 BitBucket API and POST the right command, as in this thread:

POST /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests

即:

curl -u user:myPW -H "Content-Type: application/jso https://bitbucket.server.com/rest/api/1.0/projects/myProject/repos/myRepo/pull-requests -X POST --data @req.json

有数据:

{"title":"test","description":"test","fromRef":{"id":"refs/heads/test-branch","repository":{"slug":"test-repo","name":null,"project":{"key":"myProject"}}},"toRef":{"id":"refs/heads/master","repository":{"slug":"myRepo","name":null,"project":{"key":"MyProj"}}}}

您可以通过 curl 使用 Bitbucket pull requests API

curl https://api.bitbucket.org/2.0/repositories/my-username/my-repository/pullrequests \
-u my-username:my-password \
--request POST \
--header 'Content-Type: application/json' \
--data '{
    "title": "My Title",
    "source": {
        "branch": {
            "name": "staging"
        }
    }
}'