GET pull request merge commit sha from download request number using github api

I am trying to use the github api (via githubot https://github.com/iangreenleaf/githubot ) to GET a merge merge request using pull the request number.

I can get the correct answer (example here in the "get one click request" section: https://developer.github.com/v3/pulls/ ), but merge_commit_sha gives me this error:

fatal: bad object 304fc816f33f808080c9c87895eea2d66081d373 

When I compare 2 pages on github, I see merge_commit_sha from the commit page, but I see another commit command on the merge pull request page. Both parents are the same, but the merge pool is different. The one that returns from the api call does not work, but the other allows me to undo the commit of the transfer request through

 git revert -m 1 commit_sha 

Here are some examples of screenshots. enter image description hereenter image description here

So, this leads me to two questions: - What is the difference between these 2 commit sha and why does only one job work to return a pull request?

  • How to get merge merge request using github api?

Thanks.

+3
source share
2 answers

GitHub has the deprecated merge_commit_sha attribute because it is confusing. As they describe here :

  The merge_commit_sha attribute holds the SHA of the test merge commit 

This means that GitHub creates a special branch in which they combine the main and request request branches, and merge_commit_sha indicates that the surrogate merge, but you do not have it in your local repo. You will need to get the special pr/<pull_request_id>/merge branch to see this commit.

Good thing you can do this before merging the pull request. And tools like the Jenkins GitHub pull query builder use this technique. Meanwhile, commit_sha is the actual merge, so you can return it.

So, if still unclear, merge_commit_sha really gives you the correct commit command, but to use it you must first extract the pr/<pull_request_id>/merge branch. To avoid future obsolescence issues, you can get the head commit of the above merge branch instead of using merge_commit_sha .

By the way, if you are building something with Hubot, you can check out this book (shameless plugin). It includes a chapter on GitHub integration.

+2
source

You can get a list of events for transfer requests, and then find the β€œmerged” event:

http://developer.github.com/v3/issues/events/#events-1

The commit_id attribute of this event will contain the merge commit sha.

+2
source

Source: https://habr.com/ru/post/1205761/


All Articles