GitHub Rest API similar git rev-list command

Viewed 173

i get all commits of a repo with:

curl  -I -k -u ${api_user}:${api_token} "${api_url}/commits?sha=${api_branch}&per_page=1" | sed -n '/^[Ll]ink:/ s/.*"next".*page=\([0-9]*\).*"last".*/\1/p'

Is there a similar way for git rev-list with the GitHub Rest API and curl?

Thanks in advance!

1 Answers

The GitHub API v3 Commits API is the closest:

GET /repos/{owner}/{repo}/commits

It could be the very same you are using, depending on what ${api_url}.
Like git rev-list, it includes a commit reference from which the list starts.
And a path, to only list commits modifying the given <paths>.

It would not, howver, allow more complex commit specification, like git rev-list foo bar ^baz, which lists all the commits which are reachable from foo or bar, but not from baz.

For that, you would need a GraphQL query, using Commit object, like in [those] examples.6

Related