Link to a PR's raw patch from the UI

Issue #8323 open
nickspiers created an issue

Using a git fork-clone-pull workflow, it's necessary sometimes to demo the pull request from the forked repository.

Currently you have to make sure you have all the appropriate permissions and pull down the forked repo which uses unnecessary time, space and bandwidth.

I propose a patch url where you could download a git patch that could be applied temporarily to your own pulled repo to demo the pull request.

Comments (38)

  1. George Notaras

    This is definitely a missing feature. It would be even better if the patch contained the correct contributor name <email>, like Github does.

  2. Christopher Meng

    +1 here!

    Github can use .patch at the end of any commit, BB should also support this in a similar way.

  3. Andy Postnikov

    +1 here

     curl -u user:password https://bitbucket.org/api/2.0/repositories/{user}/{repo}/pullrequests/{pull_no}/patch -L -o name.patch
    
  4. fm-admin

    Another +1 for changes to the UI to make it -simple-possible to retrieve the URL for the patch file.

    Also thanks Andy Postnikov for the curl command as this solved my problem subsequently retrieving the patch file once I knew the URL for it (the destination repo is private).

    Using your solution, I was then able to use this one-liner to apply the patch within my local (clean) git directory:

    curl -u user:password https://bitbucket.org/api/2.0/repositories/{user}/{repo}/pullrequests/{pull_no}/diff -L | git apply -
    

    Update: unbelievable - now https://bitbucket.org/api/2.0/repositories/{user}/{repo}/pullrequests/{pull_no}/diff is just returning me a 403 (Forbidden) response.

    Latest update 10/7/15: slight change to the URL got this working again. Here's what works for me now:

    curl -u username:password https://api.bitbucket.org/2.0/repositories/{username}/{reponame}/pullrequests/{pull_no}/diff -L | git apply -
    
  5. Johan Walters

    Is 2.0 api also available for bitbucket server? I cannot find any relevant information on this. Version 1.0 of the rest api seems to work though, but that doesn't give what I need.

  6. Silas Baronda

    +1, seriously. I love the GH feature that any SHA URL can be changed to generate a diff or patch by adding either .diff or .patch to the end of the url. Would love this feature with BB Server.

  7. Kalpit_Jain

    +1, This is a much needed feature to simplify and ease the patch generation from a pull-request. It will be great if the patch url can be exposed to the users.

  8. podsiadly

    Had the same need, but worked around it. I created a branch, edited pull request destination to be that new branch, merged pull request there and pulled the branch to my local git repo.

    Link to download patch would be much more convenient

  9. Jeffrey Harris

    It's really painful not to have this for bitbucket server.

    I can't figure out how to construct a XPC-RPC request for this by hand, even. It's really painful to have to use Bitbucket's broken merge feature to accept patches.

  10. Jo Paulger

    Please, please, please make this easier to do bitbucket? Even if it's just adding fm-admin's 2nd (updated) command from 2017-07-09 to a pull request page? (that just worked for me)

  11. Ying-wen Zhang

    Is this feature done? The patch should can be downloaded and modified by the reviewer. Gerrit has it too.

  12. Drew Parsons

    The raw diffs are already available for each individual commit listed under the Commits button of the PR. An alternative service which complements this issue is to provide a link to a zipfile or tarball containing all the individual diff files for each commit in the PR.

    Depending on why you want access to the raw patch of the PR (or how many commits it contains), in some cases it can be convenient to work with the separate patch files for each commit rather than a single patch file for the whole PR.

  13. Jeffrey Harris

    I have never been able to find a download button that returns a unified diff. I only find links that download the state of the repository, which is really not what I want.

  14. Jeffrey Harris

    I can’t figure whether the feature @Drew Parsons is talking about just doesn’t exist in my corporate installation, or we’re talking about different things, but this seems like it’s got to be about the easiest request ever.

    What I see in the “commits” section:

    • a button to download a .zip file containing the entire source code, with no diff, and none of the commit author information.

    What I want:

    • a button to download the exact output of running: git format-patch master..HEAD which would contain the author message, and the unified diff

    I run into this practically every day. It means I end up giving other people access to my repository, when I really don’t want to, to just work around this missing feature.

  15. Nikita Skiba

    @Jeffrey Harris it seems like the user also can't download ZIP-file if he do not have access to the PR author’s repository. But there is no rational logic to conceal patch if we could see the same diff in the Bitbucket PR view.

  16. Drew Parsons

    @Jeffrey Harris just to clarify, what I meant was that it would be useful to have button that generates the zipfile of individual diff files. It doesn’t exist yet, in the same way that there is no button to generate the single diff file for a PR, which is requested in this Issue.

  17. Log in to comment