Bitbucket Pull Request refspec

余生颓废 提交于 2020-01-24 05:49:07

问题


I've searched Atlassian docs and found this ref/pull-requests/$PR_NO/from and when I try to fetch that, I encounter this error Couldn't find remote ref refs/pull-requests/1/from. Is there a way to enable this ref? Or are webhooks the only option? I am trying a CI setup with Bitbucket.

(We're on the 10-user paid plan)


回答1:


This is now possible. You just need to add a line like this to your <repo_root>/.git/config:

[remote "origin"]
    url = ...
    fetch = ...
    fetch = +refs/pull-requests/*:refs/pull-requests/*

When you fetch, you'll see a whole new set of refs appear:

$ git fetch origin
remote: Counting objects: 252, done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 82 (delta 20), reused 0 (delta 0)
Unpacking objects: 100% (82/82), done.
From ...
 * [new ref]           refs/pull-requests/300/from  -> refs/pull-requests/300/from
 * [new ref]           refs/pull-requests/300/merge -> refs/pull-requests/300/merge
 * [new ref]           refs/pull-requests/302/from  -> refs/pull-requests/302/from
 * [new ref]           refs/pull-requests/323/from  -> refs/pull-requests/323/from
 * [new ref]           refs/pull-requests/323/merge -> refs/pull-requests/323/merge
 * [new ref]           refs/pull-requests/344/from  -> refs/pull-requests/344/from
 * [new ref]           refs/pull-requests/344/merge -> refs/pull-requests/344/merge
 * [new ref]           refs/pull-requests/350/from  -> refs/pull-requests/350/from
 * [new ref]           refs/pull-requests/350/merge -> refs/pull-requests/350/merge
 * [new ref]           refs/pull-requests/355/from  -> refs/pull-requests/355/from
 * [new ref]           refs/pull-requests/355/merge -> refs/pull-requests/355/merge

*/from gives you PR branch heads; */merge gives you the result of merging the PR with your target branch.

For more details, see Pull request proficiency: Fetching abilities unlocked!




回答2:


This is unsupported by Bitbucket: https://bitbucket.org/site/master/issues/5814/reify-pull-requests-by-making-them-a-ref




回答3:


Supported by Bitbucket Server (Stash) (Self-hosted)

Stash supports refspecs and is available thru the following command

git config --add remote.origin.fetch '+refs/pull-requests//from:refs/remotes/origin/pr/'

You can check against your .git/config file to see if it's setup properly

[remote "upstream"]
url = git@stash.atlassian.com:docker/libswarm.git
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch = +refs/pull-requests/*/from:refs/remotes/upstream/pr/*

https://www.atlassian.com/blog/archives/how-to-fetch-pull-requests

Unsupported by Bitbucket Cloud (bitbucket.com)

Bitbucket Cloud currently do not support PR on refspec, available option would be to either Poll Bitbucket's Git or API Endpoint

https://jira.atlassian.com/browse/BCLOUD-5814

Given that the request have been on hold for 7 years it would be wise to not wait for the refspec implementation (as of Nov 2019)



来源:https://stackoverflow.com/questions/35216431/bitbucket-pull-request-refspec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!