Python Forum
How to list repository contributors and their commits using pygithub3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to list repository contributors and their commits using pygithub3
#1
I have a Github user in which I have been granted the access to see an organization called 'W-Org' with all its repositories. It has repo-A and repo-B.

If I click on W-Org and navigate to repo-A, then click on 'Graphs', I can see each contributor to this repo-A with his commits (no of commits, lines added, lines removed).

How can I write python code using pygithub3 to get into this? All what I could get is a list of repositories for this org using:


gr = gh.repos.list_by_org('W-Org',type='all').all() 
and a list of all contributors (not linked to each repo) using:

gh.orgs.members.list('W-Org').all()
How to link this repository with the contributor and then get his commits? 

I also tried this code, but it gives me 'Not found 404!' although I can see and click on repo-A and see its contents.


gh.repos.commits.list('repo-A').all()
Reply
#2
Show enough code to make a runable snippet
Reply
#3
Hi

below is the code i wrote, if you want to run it, you will need to use your Github user and password instead of mine.  Thank you.


import numpy as np
import pandas as pd
from pandas import Series, DataFrame
from pygithub3 import Github
import ConfigParser


config = ConfigParser.ConfigParser()
config.read("/etc/ammar_config.txt")   
pass_secret = config.get("configuration","password")

gh = Github(user='ammar-khwaireh', token=pass_secret)

# get org repositories
gr = gh.repos.list_by_org('W-Org',type='all').all()

contributors = gh.orgs.members.list('W-Org').all()

commits = gh.repos.commits.list(repo='repo-A').all()
Reply
#4
Quote:How can I write python code using pygithub3 to get into this?
I think this is what you are looking for https://developer.github.com/v3/pulls/
Reply
#5
Thanks for your reply.

Actually pygithub3 is a wrapper for github API ( the link you have sent) written in python. The code snippet i have written above is calling this API.
but my issue here is how to write code in pygithub3 using python to call github API to get the repository contributors' commits. i mean, looping through org repositories, loop through repository contributors, and get their commits.

thanks
Reply
#6
I know that. But you are using that wrapper, and the (pygithub3) pull command is part of the wrapper
which you are already using! (gh)
Reply
#7
Do you have python code which can pull repository statistics using pygithub3 ? (github API in this link https://developer.github.com/v3/repos/st...mit-counts)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020