Using the GitHub API (v3) I'd like to figure out which branches a commit appears on. I didn't find a way to directly query this, either through repo commits or the commit data objects. An alternate solution would be to list all the branches, and compare with their HEAD; I guess the comparison would fail if the commit is not on the given branch.
Is this supported via the current API, and I just missed it? If not, do you have a (better) workaround?
That's not possible directly via the GitHub API.
for each branch, compare the branch with the SHA:
https://api.github.com/repos/:user/:repo/compare/:branch...:sha_of_commit
If the value of the status
attribute in the response is diverged
or ahead
, then the commit is not in the branch. If the value of the status
attribute is behind
or identical
, then the commit is in the branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With