Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get git commit from short hash using Github API

I have a short hash that should identify a commit on my repository. I'd like to use this to get the long hash, without having to use git locally (I'm aware I can do this using 'git show 918fe27', if I have a local copy of the repo, which I don't).

Say my hash is 918fe27:

1)https://github.com/$USER/$REPO/commit/918fe27 (works, but html response)

2)https://api.github.com/repos/$USER/$REPO/git/commits/918fe2742c80b06661444857a34fcdb29c76df36 (works, but I don't have the full hash)

I'd like to use (2), but with only the short hash, but it seems that it just doesn't work that way, even though the non-api version of the same thing (1) works fine.

Does anyone know how to do this?

like image 205
turnerba Avatar asked Mar 04 '14 19:03

turnerba


1 Answers

Give this a try https://api.github.com/repos/$USER/$REPO/commits/918fe27

Example: https://api.github.com/repos/rails/rails/commits/abe6484

Docs: http://developer.github.com/v3/repos/commits/#get-a-single-commit

like image 78
Ivan Zuzak Avatar answered Sep 28 '22 18:09

Ivan Zuzak