我想使用 Python 的 Github API 来获取每个存储库并检查对存储库的最后更改。
import git
from git import Repo
from github import Github
repos = []
g = Github('Dextron12', 'password')
for repo in g.get_user().get_repos():
repos.append(str(repo))
#check for last commit to repository HERE
这会获取我帐户上的所有存储库,但我希望能够获取其中每个存储库的最后更改,并且我想要这样的结果:
13:46:45
我也不介意是否是 12 小时时间。
最佳答案
根据文档,您可以获得的最大信息是提交的 SHA 和提交日期:
https://pygithub.readthedocs.io/en/latest/examples/Commit.html#
以你的例子:
g = Github("usar", "pass")
for repo in g.get_user().get_repos():
master = repo.get_branch("master")
sha_com = master.commit
commit = repo.get_commit(sha=sha_com)
print(commit.commit.author.date)
关于python - 使用 Github API 获取所有存储库的最后一次提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57229005/