Getting Github individual file contributors

后端 未结 4 650
后悔当初
后悔当初 2020-12-31 11:23

I am planning to build a plug-in for Sphinx documentation system plug-in which shows the names and Github profile links of the persons who have contributed to the documentat

4条回答
  •  耶瑟儿~
    2020-12-31 12:00

    Until and unless it is not necessary to interact with GITHUB API directly one can get the list of contributors by cloning the repo down and then getting into the cloned directory and then getting the list from the github log file using shortlog command

    import os 
    import commands 
    
    cmd = "git shortlog -s -n"
    
    os.chdir("C:\Users\DhruvOhri\Documents\COMP 6411\pygithub3-0.3")
    os.system("git clone https://github.com/poise/python.git")
    os.chdir("/home/d/d_ohri/Desktop/python")
    output = commands.getoutput(cmd) 
    print(output)
    raw_input("press enter to continue")
    

    There is one more way to list contributors in case one wants to use GITHUB API, we can use pytgithub3 wrapper to interact with GITHUB API and get list of contributors as follows using list_contributors:

    from pytgithub3.services.repo import Repo
    r = Repo()
    r.lis_contributors(user='userid/author',repo='repo name')
    for page in r:
        for result in page:
              print result
    

提交回复
热议问题