Reputation: 2232
Imagine we have following GitHub repository: https://github.com/pytorch/pytorch
On the right side of the page, you can see the Used by
and Contributors
count. Is it possible to get that information on a monthly basis, say for the past x months/years?
Working with the wayback machine doesn't seem perfect here, also because the data is incomplete, hence I wondered what mechanisms can be used to give you historical data.
Upvotes: 3
Views: 2622
Reputation: 1270
Yes, It is possible to get the statistics about a commit. There are two ways of doing this.
Command Line method
To get information about the commits in last one month from command line you can use following command
git shortlog --since=2021-01-06 --until=2021-01-07 -sn
Here the --since and --until is self explainatory, whereas -s is for summary and -n is for numbered.
On pytorch this gives output as follow. I have trucated the response to keep only 5 top authors.
Please note that you need the repository cloned on your local setup.
GitHub API Method
curl --location --request GET 'https://api.github.com/repos/pytorch/pytorch/commits?since=2021-01-06&until=2021-01-07' \
--header 'Accept: application/vnd.github.v3+json'
You can find the complete documentation about the API here.
There is no direct API to fetch the number of authors who have commited in last one month as the command line.
The response for the above API will need to be processed to get the count. Whereas, you can also add the parameter of author to get the commit history and effectively count of commits in last month by following API.
curl --location --request GET 'https://api.github.com/repos/pytorch/pytorch/commits?since=2021-01-06&until=2021-01-07&[email protected]' \
--header 'Accept: application/vnd.github.v3+json'
Please note that the header Accept: application/vnd.github.v3+json
is recommended and not mandatory.
Depending on your exact use-case. We can use the right API's from the documentation.
Upvotes: 0
Reputation: 1328322
You would need to call a third-party tool, month by month, in order to get that kind of activity log.
For instance: git-stats -s '1 June 2021' -u '30 June 2021'
Or: askgitdev/askgit
can make queries, again for a given author/month, to your Git repository.
Upvotes: 1