Reputation: 2564
I have a pretty good understanding of how git (and github) works, but one thing frustratingly eludes me.
When I see a 'push' webhook from github, it'll contain a lot of nice info, incluing an array of commits, and the head commit, etc. the webhook payload includes the 'ref' of the head commit.
However, given any specific commit, I cannot seem to find any way to query github via the API to see if that commit has any ref(s).
Use case: I know a SHA. I'm curious if it's the actual commit that a branch ref points to. I understand that not all commits have a ref, but I need to test a single commit regardless.
This simply has to be possible, but I'm so wrapped around the axle I'm not seeing it.
Ultimate use case: it seems consistent that a merge has more than one 'parent', and those parents represent the 'to' and 'from' branches involved in the merge. Given a merge push, I must discover the source and target branches. Obviously I cannot use the 'message' as this, while the default is useful, is overridable and therefore untrustworthy.
Dead in the water if I can't figure this out.
Upvotes: 0
Views: 228
Reputation: 2564
A trip to Subway proved moderately effective. Hoping there's a more efficient way, but I can query all the refs for a given repo, then map the sha in question to that array looking for a match.
Any suggestions for a more efficient method of matching than pulling down hundreds of refs just to attempt to match one are appreciated.
Upvotes: 1