Counting and analyzing commits in Github organization (not repo)
Asked Answered
P

2

6

I'd like to count the commits of 2012 in http://github.com/plone and http://github.com/collective

Are there any tools to do this - provide statistics for Github organizations?

Do I need to write my own script to scrape the repositories, check out them individually and count commits?

Portcullis answered 23/4, 2013 at 8:21 Comment(0)
M
3

Here is how I'd do it:

  • use the GitHub API to enumerate the repositories (see the JSON for Plone for an example). Loop over the JSON result and with each:
    • Check out the repository (the git_url URL) with git clone --bare; only the git info, no working copy. This creates a <repository_name>.git> directory, say plone.event.git if you cloned git://github.com/plone/plone.event.git.
    • Count the revisions with git --git-dir=<git_directory> rev-list HEAD --count; outputs the count to stdout, so subprocess.check_output() should do the job just fine.
    • Remove the .git directory again

That only requires 2 API calls, so you avoid being rate limited; paging through all the commits with the API would require too many requests to count all the repository commits, checking out a bare repository copy would be faster anyway.

Mahdi answered 23/4, 2013 at 8:58 Comment(0)
H
2

The herdstat tool can be used to generate contribution graphs known from GitHub user profiles but for individual repositories or aggregated ones for multiple repositories, e.g., all repositories in a GitHub organization.

The tool is packaged as a Docker image and can be used as follows:

docker run --name herdstat-dev -it herdstat/herdstat:v0.4.0 \ 
    /herdstat -r plone contribution-graph -u 2012-12-31
docker cp $(docker ps -aqf "name=herdstat-dev"):/contribution-graph.svg .

The graph is generated for a 52 week time frame ending with the date specified via the -u / --until flag.

The second command copies the generated graph from the container to the current directory.

The tool is still in its early stages, but it generates informative and nice looking contribution charts like this one that include also the number of contributions in the respective time frame.

Disclaimer: I am the author of herdstat.

Hannigan answered 11/1, 2023 at 20:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.