It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

What is the URL of a pull request

Jorn Klungsoyr Apr 28, 2013

Hi,

I simply need to know how I can download a patch or diff for a pull request.

This is to apply it locally on my private clone before accepting the pull request online.

In github this is simply done by adding .diff or .patch to the end of the pull request - Is there not something similar? Or can this be done in another way?

Ideally I would want to do something like this:

wget URL_OF_PULL_REQUEST | git am

6 answers

1 accepted

2 votes
Answer accepted
manthony Apr 29, 2013

Jorn,

Sorry for the misunderstanding. You want the raw diff. We are currently building a complete pull request API. Unfortunately it's not been finalized yet and so it cannot be published at this time.

If you want, you can take the current, undocumented and unpublished version for a spin: https://bitbucket.org/api/2.0/repositories/pypy/pypy/pullrequests/

But be aware that this API will most likely change before it's being released and so expect breakage. When we do release the final API, it will be announced on our blog.

Hope this helps, finally. :-D

Mary

Jorn Klungsoyr Apr 29, 2013

Hi Mary,


YES! Thank you! :)

So this is what I wanted:
https://bitbucket.org/api/2.0/repositories/user_name/repository/pullrequests/1/diff

BUT for some odd reason that forwards to something like:
https://bitbucket.org/api/2.0/repositories/user_name/respository/revspec/pull_request_user/repository:cb24b4f56abc..xb43d34gs19c

I would therefore suggest that the API does not forward to a different URL, but provide the diff - witout a redirect.

I would also suggest that you add patch as an endpoint

With diff you can use git apply but with patch you can use git am.

Hope this will be improved in the api.

Thanx for your help!

Best Jorn

1 vote
Jorn Klungsoyr Apr 28, 2013

Hi Mary, thanx for the reply.


I've gone through the two links, but I don't see a convenient way of doing this without having to go through a number of manual steps.

Take the following scenario.

Say we have 2 different git repos.

A. our_system (for the team)

B. our_system (for a developer, and is a branch of A)

A single pull request is made for 1 or more revisions made in B.

In repo A this would be available under a URL something like this:
https://bitbucket.org/our_team_user/our_system/pull-request/1/this_pull_request_fixes_the_system

Before I accept and comitt pull request 1 into repo A, I would want to test run this on my own machine.

I have a unaltered clone of repo A on my machine.

What command could I use to fetch pull request 1, download it to my machine and apply it to my local clone of repo A?

The examples you mentioned does not seem to focus on a pull request but rather on merging in one or more changesets?

I should note that I don't have read permissions on repo B, but I have full permissions on repo A - so I can't just fetch the commits directly from repo B.

I should mention that for github it is very easy to get the diff of a particular pull request. An example from stackoverflow is:
https://github.com/weppos/whois/pull/90
https://github.com/weppos/whois/pull/90.diff
https://github.com/weppos/whois/pull/90.patch

The above would provide everything found in one pull-request and can be applied using git am.

Thanx for any inputs you may give.

Best

Jorn

0 votes
manthony Apr 28, 2013

Joen,

You'll want to use git fetch to get the remote --- http://www.git-scm.com/book/en/Git-Basics-Working-with-Remotes explains about fetch and remotes. Then you can merge...if you want a particular commit you might want to look at git cherry pick once you have the remote.

Mary

0 votes
manthony Apr 29, 2013

Jorn,

It sounds like you want a pastebin type feature similar to Gist. We don't have that yet. You can add your voice to the issue for this here:

https://bitbucket.org/site/master/issue/516/mercurial-backed-pastebin-bb-672

Until this is implemented, you'll need to do this manually. If Bitbucket can't pull a request -- if it is conflicted, it does provide you with the list of commands to excecute -- but it is more than one.

Mary

0 votes
Jorn Klungsoyr Apr 29, 2013

Hi Mary, no I'm not looking for gist ;)

I'm only looking for a simple way to get the content of a pull request as a downloadable patch/diff
Just like you can do in github - without using gist.

The issue would be the same whether I have read permissions on repo B in my example above.

There are no conflicts on the code - but I only want to be able to get the content of a specific pull request.

If you look at the example URLs from github, you'll see what I'm looking for.

Thanx for your help.
Jorn

0 votes
Stefano Tortarolo Jun 11, 2013

Hi,
this is quite a crucial feature!

Let's say that Dev1 created a pull request for Dev2. How is Dev2 supposed to try that code locally?

In a Github-like scenario, Dev2 would create a local branch related to that pull request...
It seems like it's not possible to do the same thing in Stash?

Thanks in advance,
Stefano

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

1,939 views 1 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you