【发布时间】:2019-06-28 14:37:47
【问题描述】:
我查看了文档甚至源代码,但似乎无法弄清楚如何使用 github3.py 库获取提交的时间戳。我很确定它在那里,因为它是一个时间戳。
【问题讨论】:
标签: python github github3.py
我查看了文档甚至源代码,但似乎无法弄清楚如何使用 github3.py 库获取提交的时间戳。我很确定它在那里,因为它是一个时间戳。
【问题讨论】:
标签: python github github3.py
因此,如果您想获得与存储在 GitHub 中的 git 提交相关的时间戳,那么您需要做一些事情:
因此,如果您有存储库,您可以像这样检索它:
repo = github3.repository('username', 'repositoryname')
这样,您应该能够像这样获得git_commit 数据:
commit = repo.git_commit('sha1-of-git-commit-i-care-about')
您的commit 值是github3.git.Commit 对象的一个实例,该对象具有author 和committer 属性,这些属性类似于字典
"author": {
"date": "2014-11-07T22:01:45Z",
"name": "Scott Chacon",
"email": "schacon@gmail.com"
},
"committer": {
"date": "2014-11-07T22:01:45Z",
"name": "Scott Chacon",
"email": "schacon@gmail.com"
},
所以你可以总结一下:
commit.author["date"]
我建议使用像 dateutil 这样的实用程序来解析这些时间戳。
【讨论】:
github3.api.repository 已弃用。请改用GitHub.repository。