Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to find a merge-commit for the pull-request via Stash REST API?

Ivan Lezhankin October 6, 2013

I have the merged pull-request id, and I want to get the hash of it's merge-commit.

How can I do it?

1 answer

1 accepted

0 votes
Answer accepted
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 6, 2013

Hi Ivan,

I hope I don't lead you astray but I'm not actually sure if that's possible from REST. We certainly have to the from/to refs in the core REST API, but that's not quite what you're after?

This might sound a little strange but you _could_ just use Git's smart HTTP ref advertisement instead. This is what Git uses as part of fetch/clone. You can see what I mean by running the following:

GIT_CURL_VERBOSE=1 git ls-remote origin

The environment variable is just so you can see the URL, which looks like:

curl "http://host:port/scm/PROJECT/repo.git/info/refs?service=git-upload-pack"

At that point you could just grep for the hash against refs/pull-requests/$PR/merge-clean.*

Does that help?

Charles

* Just FYI in an upcoming version of Stash we're planning on cleaning up some of these refs and merge-clean will most likely become merge. Just so you know.

Ivan Lezhankin October 6, 2013

GIT_CURL_VERBOSE=1 doesn't work for me, but your point is clear.

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 6, 2013

Hi Ivan,

As one of my colleagues just pointed out, if you're looking for the commit that was actually merged then my previous advice is going to be wrong. merge-clean is an internal ref that will always differ from the final merge commit.

Apologies for the confusion. I can't think of anything that will return the commit hash you're looking for. :(

Charles

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events