Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 4

How do I get the creator of a file using the Github API?

Solved! Go to Solution.

Hello! I am using the Repo Commits API to get a list of commits. How do I find out the github user who first committed the file (the creator)?  Thanks in advance!

3 Replies
Highlighted
Community Manager
Message 2 of 4

Re: How do I get the creator of a file using the Github API?

Hi @mkay581,

 

This API supports the same qualifiers as GitHub.com. To learn more about the format of the query, we recommend checking out these guides:

 

 

If it helps, we also expose an API for searching commits:

https://developer.github.com/v3/search/#search-commits

 

That endpoint has an author email and committer email qualifier that might be helpful:

https://help.github.com/en/articles/searching-commits#search-by-author-or-committer


I hope this helps, AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!

Highlighted
Copilot Lvl 2
Message 3 of 4

Re: How do I get the creator of a file using the Github API?

Thanks for the information and this is slightly helpful but still doesn't answer my question. How would I find the creator of a file by using the Search API to search commits? Or am I missing something? 🤔

Highlighted
Solution
Community Manager
Message 4 of 4

Re: How do I get the creator of a file using the Github API?

Hey @mkay581,

 

You can try:

 

GET /repos/:owner/:repo/commits

for example:

https://api.github.com/repos/atom/atom/commits

 

query resultquery result

Whereas, the first committer is Lee Dohm.

 

Or, on GitHub enterprise:

 

Use the Commits API to list committer information for the first commit.

 

Be sure to adjust the ORG and REPO variables 

curl -u LOGIN:TOKEN https://HOSTNAME/api/v3/repos/ORG/REPO/commits | jq '[last(.[])] | .[] | .committer.login, .committer.html_url'

 

For example, using SuperDevs/RepoForTestOne it would be:

curl -u LOGIN:TOKEN https://HOSTNAME/api/v3/repos/SuperDevs/RepoForTestOne/commits | jq '[last(.[])] | .[] | .committer.login, .committer.html_url'

 

Example results:

testone <------------- The login of the user who made the first commit on the repository.


I hope this helps, AndreaG

Mark helpful posts with Accept as Solution to help other users locate important info. Don't forget to give Kudos for great content!