Difference of refs/pull-requests/<ID>/merge and refs/pull-requests/<ID>/from

When a pull request created, I saw following remote branch created automatically,

  • refs/pull-requests/<ID>/merge
  • refs/pull-requests/<ID>/from

What is the difference of these two?

 

BTW, I am trying to polling git to check new pull requests and automatically test them (I have no permission to change to Bitbucket server's setting to add a pull request notification plugin).

1 answer

1 accepted

2 votes
Accepted answer

Hi,

First I want to point out that this is an internal implementation detail, and not part of our API. Anything you build that depends on these files may stop working after an upgrade to Bitbucket Server without warning. A better alternative may be to talk to your System Administrator about installing a plugin.

To answer your question, the "from" ref points to the head of the source branch of the PR. The "merge" ref points to a merge commit between the "from" ref and the head of the target branch. To understand why we track these it might help to read this blog post.

You should note that these refs are not automatically updated when a change is made to the branch. A user must view the PR in their browser for the refs to be updated. You can read this answer to understand why. You cannot rely on these refs being updated in order to pick up changes to the pull request as they happen.

Another option may be to look at our REST API - you can use this endpoint to retrieve all pull requests in a repository. From there, fromRef.latestCommit for each PR in the response will tell you the commit at the head of the source branch, similar to the "from" ref, except the value from the REST API will update automatically. 

Hopefully this helps clarify things.

Cheers,

Isabella - Atlassian

Thank you very much! It is very helpful.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

426 views 6 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you