Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github V3 API : list contributors

I have read the following doc (https://developer.github.com/v3/repos/#list-contributors) to list contributors on a repository I have worked on, and I can see that one person who committed several times does not appear, and myself only have 3 contributions whereas I pushed most of our 301 commits.

I don't really get what this end-point returns, but it does not look accurate. The doc is not very detailed about that, does anybody know something that might explain it ?

like image 773
Dici Avatar asked Apr 04 '16 18:04

Dici


People also ask

How do I get a list of contributors on GitHub?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Insights. In the left sidebar, click Contributors. Optionally, to view contributors during a specific time period, click, then drag until the time period is selected.

How do I list all repositories in GitHub?

How To List All Public Repositories Belonging to a User? So, to list all public repos from a user, send a GET request to https://api.github.com/users/<USER-NAME>/repos , replacing with the actual user from whom you want to retrieve the repositories.

How do I see stats on GitHub?

You can find the link to the left of the nav bar. You should have a look to repoXplorer, an open source project I develop. It is able to compute stats for a project (a group of git repositories) as well as for a contributor and a group of contributors. It provides a REST interface and a web UI.

What is PyGitHub?

PyGitHub is a Python library to access the GitHub REST API. This library enables you to manage GitHub resources such as repositories, user profiles, and organizations in your Python applications.


1 Answers

I submitted my question to the Github API's support, and they made me an amazingly detailed answer. Here it is (shortened):

It looks like your missing commits were authored with an email address not linked to your GitHub profile. You can find the missing email by adding ".patch" to the end of a commit URL, then looking at the "From:" line. Once you have the email, you can link it to your profile by following these instructions:

https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user

After you link your email to your account, any valid missing contributions will be backfilled and new ones should show up automatically.

For example, when I check out the Projet-merou's commit history:

https://github.com/jxw1102/Projet-merou/commits/master

When I choose the latest commit with your GitHub username as its author and add .patch to the URL like so:

https://github.com/jxw1102/Projet-merou/commit/f5bf30243ab99efc40802d3d78c08e49839ec9c9.patch

I see this on the second line:

From: Dicee [email protected]

Adding that email will backfill any missing valid contributions. After you do that, calling the API should show the expected result.

API Endpoints: Contributors and Contributors Statistics

I have written up some notes about each endpoint below. Let me know if you have any questions!

/repos/:owner/:repo/contributors

When you call GET /repos/:owner/:repo/contributors, the GitHub API will list contributors to the specified repository, sorted by the number of commits per contributor in descending order. Contributors data is cached for performance reasons. This endpoint may return information that is a few hours old. Git contributors are identified by author email address. This API attempts to group contribution counts by GitHub user, across all of their associated email addresses. For performance reasons, only the first 500 author email addresses in the repository will be linked to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information.

If you call this endpoint with anon=1 specified, the API will return a count of all commits on the default branch, including commits that aren't associated with any user on GitHub. Here's an example:

https://api.github.com/repos/jxw1102/Projet-merou/contributors?anon=1

When anon=1 isn't specified like this:

https://api.github.com/repos/jxw1102/Projet-merou/contributors

notice how the results only show commits associated with some GitHub user and doesn't count merge commits.

/repos/:owner/:repo/stats/contributors

When you call GET /repos/:owner/:repo/stats/contributors, the GitHub API will return the contributors list with additions, deletions, and commit counts. The total denotes the total number of commits authored by the contributor.

Does that help?

All the best,
Francis
@francisfuzz
GitHub Support

like image 71
Dici Avatar answered Oct 12 '22 14:10

Dici