python - 在 GitPython 中迭代提交 b/w 2 个指定的提交
问题描述
import git
repo = git.Repo(repo_dir)
ref_name = 'master'
for commit in repo.iter_commits(rev=ref_name):
<some code here>
此代码遍历所有提交。我想迭代 b/w 2 提交。就像git log commit1...commit2
如何使用 GitPython 的 iter_commits() 方法来做同样的事情。
解决方案
repo.iter_commits(rev='1234abc..5678def')
为我工作GitPython==2.1.11
例子:
repo = git.Repo(repo_dir)
for commit in repo.iter_commits(rev='master..HEAD'):
<some code here>
推荐阅读
- python - 日期过滤器问题(python)
- java - 无法在 Tomcat 9 上运行 JSP 文件:无法设置文件的最后修改日期
- swiftui - Switch 语句不响应更改
- java - System.getenv 带有特殊字符,如 Java 中的 '%'
- python - 如何使用 BeautifulSoup 提取多个 H2 标签
- c# - 如何找到引用的 dll 中缺少哪些依赖项?
- opengl - 为什么在交换缓冲区后调用 GL.Finish 可以防止低端硬件出现大量卡顿,但在现代 GPU 上却没有?
- java - 如何在 ListDataBaseTables (NiFi) 中提供“_”作为表名格式的一部分
- javascript - Dom 不更新 Vuex 状态变量
- azure - 部署 Azure 自动化帐户 Runbook 的最佳实践