I found this gist: https://gist.github.com/kennethreitz/3709868
Im using bitbucket and I'm looking for a similar function.
Can you help me? Thank you
I found this gist: https://gist.github.com/kennethreitz/3709868
Im using bitbucket and I'm looking for a similar function.
Can you help me? Thank you
One may fetch the code from Bitbucket Server's pull requests using:
It seems the easiest way to do this is still to get a patch of the pull request. Based on this question's answer, Alexandre's comment is still the only way to do this. It uses this BitBucket API call.
I used the following bash script:
Save that to a file called
pull-patch.sh
and fill in the environment variables with your account details. The script requires that you havecurl
installed (e.g.sudo apt install curl
). Then run:And a file called
output.patch
should be created from the pull request.I followed this article Pull request Fetching.
It worked but I found out I just need add one line to the current repo, rather than create a folk repo and an upstream repo. Run this line
git config --add remote.origin.fetch '+refs/pull-requests/*/from:refs/remotes/origin/pr/*'
You can also add it manually to the file .git/config in your project.
Next run
git pull
you should see a list:Then you can run
git checkout origin/pr/666
to get the pull request changes.I found this answer and thought that it was actually possible to fetch refs for a pull request on bitbucket.
But it's not.
The answer for the OP's question is that it is NOT possible: there's been an open feature request issue about it that has been unanswered and unattended for
fourfiveSIX years.The workaround?
You can get the PR as a downloadable
.patch
file you can download and apply to a new branch you create manually. But you won't easily be able to apply updates.I figured another way out, which I've implemented in git-repo, so everybody can use it. What I'm doing is use the API to get the PR's remote and branch, and automatically create a new upstream and branch locally. That way you can get updates from the PR poster. The downside is the clutter of git remotes.