Skip to content

Instantly share code, notes, and snippets.

@marcysutton
Last active November 29, 2016 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcysutton/df4ba9c6ec8f0f3e98dc9bb5b2b519b9 to your computer and use it in GitHub Desktop.
Save marcysutton/df4ba9c6ec8f0f3e98dc9bb5b2b519b9 to your computer and use it in GitHub Desktop.
Bitbucket merge hell

Merging a pull request

To apply a pull request, make sure your local develop branch is up to date. Then, create a new branch for that pull request:

git checkout -b some-user-feature

Run the following commands to apply all commits from that pull request on top of your branch's local history:

Bitbucket

curl -L https://bitbucket.org/api/2.0/repositories/dmusser/axe-core/pullrequests/85/patch | git am -3

Note: the above URL is behind authentication. And that seems to be the issue.

Github

curl -L https://github.com/dequelabs/axe-core/pull/205.patch | git am -3

In the Github UI, you can use the new Squash and Merge feature as an alternative.

If the merge succeeds, use git diff origin/develop to review all the changes that will happen post-merge.

@marcysutton
Copy link
Author

marcysutton commented Nov 23, 2016

Bitbucket no worky. WHYYY
curl -L https://bitbucket.org/api/2.0/repositories/dmusser/axe-core/pullrequests/85/patch | git am -3

Does not work with or without git am. CURL is Forbidden at that URL. Here is the git-am response:

02:21 PM /Deque/bb-axe-webdriverjs (merge-configure $)> curl -L https://bitbucket.org/api/2.0/repositories/deque/axe-webdriverjs/pull-requests/9/patch | git am -3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   243  100   243    0     0    448      0 --:--:-- --:--:-- --:--:--   449
Patch is empty. Was it split wrong?
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Documentation link: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests/%7Bpull_request_id%7D/patch

@marcysutton
Copy link
Author

curl https://api.bitbucket.org/2.0/repositories/dmusser/axe-webdriverjs/pullrequests/9/patch
Forbidden

@marcysutton
Copy link
Author

marcysutton commented Nov 29, 2016

curl -L -u user:app-password https://bitbucket.org/api/2.0/repositories/dmusser/axe-webdriverjs/pullrequests/9/patch | git am -3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

@seancurtis
Copy link

I think the URL is wrong. I tried this and got the patch for a repo of mine (note api.bitbucket.org/2.0 instead of bitbucket.org/api/2.0 )

curl -L -u username:password https://api.bitbucket.org/2.0/repositories/dmusser/axe-core/pullrequests/85/patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment