How to get long SHA's from GitHub API after a diff?

Hi, I call the API to get a diff using curl.

curl -u user:token -H “Accept: application/vnd.github.diff” https://api.github.com/repos/user/repo/commits/7919b9733ebedd6ceb3eba59bbab31db2a16f79e 

and it returns the diff output below. I try to load that into reviewboard but it errors notifying that a long SHA is required. How can I convert the short index SHA to a long SHA using the API? I know I can convert it using this command git rev-parse <short sha> but in order to do so I need access to the local git repo which I don’t have at that time. Is there a method in the API to get diff output with long SHA’s? Thanks!

diff --git a/hello b/hello
index d1edb92..4bc6ffa 100644
--- a/hello
+++ b/hello
@@ -1 +1 @@
-hello there 8
+hello there 9

No, there isn’t a way to modify the format of the diff via the API. If you want to have complete control over the format of the diff output, you’ll have to clone the repository locally and perform the git command on the local copy of the repository.

I hope that helps!

2 Likes