Please expose "git merge-base --is-ancestor" as an API

We have a use case for determining whether one commit is a descendent of another.  Our CI infrastructure evaluates a commit in a Pull Request to see if it is “broken”.  This breakage may be the fault of the changes in the Pull Request itself, or it may be that the branch upon which the Pull Request was based had already been broken by someone else.  If we were to keep a database of the known breaking-commits and repairing-commits in the repository’s master branch, then we could easily answer the question of whether failing CI on a Pull Request’s commit was caused by the PR author.

API design suggestion:  The user’s JSON request would be formatted as:

{
    "ancestor": "abc123",
    "descendent": "def456"
}

and the response would be a boolean.  Labeling the hypothesized ancestor and descendent explicitly is a less error-prone interface than the positional arguments (I can never remember the order) of the existing git command-line interface.

Today, I suppose it may be possible to call the “list commits API” twice to determine ancestry relationship, but this is wasteful both in that it’s sending extra information over the wire and that two round trips are required.

6 Likes

Hi @kostmo,

Thanks for this feedback! We’re always working to improve GitHub and the GitHub Community Forum, and we consider every suggestion we receive. I’ve logged your feature request in our internal feature request list. Though I can’t guarantee anything or share a timeline for this, I can tell you that it’s been shared with the appropriate teams for consideration.

Please let me know if you have any other questions.

Cheers!

This feature would indeed be helpful in our use case where we have a CI server that does a shallow clone of our repository. However we also have a prerequisite gate we’d like to put in place to prevent the CI job from continuing unless there is a minimum common ancestor to the head of the branch under test. This is in order to prevent known bad builds from either corrupting testers or hardware etc that could pollute the testers during their future runs.