使用Github API从短哈希获取git commit

tur*_*rba 5 git github github-api

我有一个短哈希,应该识别我的存储库上的提交.我想使用它来获取长哈希,而不必在本地使用git(我知道我可以使用'git show 918fe27',如果我有repo的本地副本,我不知道).

说我的哈希是918fe27:

1)https://github.com/ $ USER/$ REPO/commit/918fe27(有效,但是html响应)

2)https://api.github.com/repos/ $ USER/$ REPO/git/commits/918fe2742c80b06661444857a34fcdb29c76df36(有效,但我没有完整的哈希值)

我想使用(2),但只使用短哈希,但似乎它不会那样工作,即使同一事物(1)的非api版本工作正常.

有谁知道如何做到这一点?

Iva*_*zak 5

试试这个 https://api.github.com/repos/$USER/$REPO/commits/918fe27

示例:https : //api.github.com/repos/rails/rails/commits/abe6484

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