python - 使用 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)
从我目前观察到的情况来看,提交似乎是基于存储库或用户名检索的。但是,我有一个不同存储库和用户名的列表。我是否有必要每次都提取用户名或仓库名称才能列出提交?我希望能够获得提交的日期以及历史记录中的提交文本。我正在尝试创建一个字典,其中日期是键,文本是值。
解决方案
推荐阅读
- azure - 如何跳过 U-SQL 作业中的前 n 行?
- frama-c - Frama-c:函数调用和静态变量
- angular - Typescript + Angular:将 aa 类型分配给 Type
失败 - sql - Oracle中如何获取子字符串索引
- java - 使用 Jackson 在 Java 中序列化到 JSON 时遇到问题
- css - 在鼠标单击时从锚标记中删除框阴影
- node.js - 如何使用时刻时区获取给定特定位置/时区的今天日期
- html - HTML 自适应表格(宽、高)
- android - 在 Android 上使用 Fabric
- elasticsearch - 使用 logstash 的 JDBC 连接出错