我想从GitPython中的repo(项目)获取目录(称为module)的提交次数。在
> print("before",modulePath)
> repo = Repo(modulePath)
> print(len(list(repo.iter_commits())))
当我试图打印目录中提交的数量时,它显示repo不是有效的git repo。在
- before /home/user/project/module
- git.exc.InvalidGitRepositoryError: /home/user/project/module
欢迎任何帮助或建议:) 谢谢
这是我的一个旧项目中的示例代码(未打开,因此没有存储库链接):
说明:
函数需要
^{pr2}$Repo
的实例和传递给git log
命令的相同参数。因此,在您的案例中,用法如下:在内部,
repo.git.log
正在调用git log
命令。它的输出看起来像这样:parse_commit_log
解析此输出并生成提交消息。您需要再添加几行来获得commit sha、author和date,但这不应该太难。在相关问题 更多 >
编程相关推荐