首页 > 解决方案 > 使用 PyGithub 根据 URL 获取存储库的提交历史?

问题描述

我正在尝试创建一个函数来检索存储库主分支的提交历史记录。到目前为止,这是我的代码:

from github import Github

# Custom imports and functions
import config as config

"""
    Return a list of commits for a Github URL passed in.

    @param g: PyGithub object for creating requests to fetch data
    @param url: URL of Github repository
    @return commit history formatted as a dictionary with date and commit
"""
def get_commits_from_url(g, url):
    repo = g.get_repo()
    return

if __name__ == "__main__":
    url = 'https://github.com/aau-ros/aau_multi_robot'
    g = Github(config.ACCESS_TOKEN)
    get_commits_from_url(g, URL)

从我目前观察到的情况来看,提交似乎是基于存储库或用户名检索的。但是,我有一个不同存储库和用户名的列表。我是否有必要每次都提取用户名或仓库名称才能列出提交?我希望能够获得提交的日期以及历史记录中的提交文本。我正在尝试创建一个字典,其中日期是键,文本是值。

标签: pythongithub-apipygithub

解决方案


推荐阅读