Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

get commit hash by pull request ID

AlonKaganArgus January 7, 2019 edited

Hi there

I want to change the build status via REST API. So I use:

/2.0/repositories/{username}/{repo_slug}/commit/{node}/statuses/build

but, I have to provide {node}, which is "The commit's SHA1."

I've seen that I can get the commit's SHA1 using /2.0/repositories/{username}/{repo_slug}/commits.

But at no other place (that I could find). And there is no identifier of which pull request is which.

Is there a way to get a commit's SHA1 by pull request id?

 

EDIT: I found a way: /2.0/repositories/{username}/{repo_slug}/pullrequests/{pull_request_id}/commits.

It lists the commits of a specific pull request. But I am interested in the latest one. can I be sure that the first commit in the list is the latest one?

1 answer

1 accepted

0 votes
Answer accepted
Julius Davies [bit-booster.com]
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.
January 8, 2019 edited

 

The docs don't really say much about the commits this particular REST endpoint returns.

I'm sure if you test it you can figure out what it currently does, and there's a strong likelihood the current behaviour will be stable and reliable for a long time.

But if you're paranoid you could run all the commits it finds through this command (using a local clone):

git merge-base --independent <commits...>

That will return the "tip" commit among the commits supplied.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events