gitpython中hexsha获取提交对象

2024-09-28 19:25:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图查找在两个特定提交之间签入的提交的内容。在

在git中我会做git rev-list --ancestry-path <older_commit_sha>..<newer_commit_sha>。在

在gitpython中,由于看起来没有一种直接的方法来实现,所以我通过repo.git.execute()调用确切的命令。 输出是一个提交id字符串(hex-SHA)。在

现在,gitpython中有没有一种方法可以从execute()给出的十六进制SHA开始创建一个有效的Commit对象吗?在


Tags: path方法git内容executerevgitpythonlist
1条回答
网友
1楼 · 发布于 2024-09-28 19:25:28

在经过多次试探之后,考虑到这个问题没有得到太多的牵引力,我求助于使用.execute()。 具体来说:

commits = repo.git.execute(['git', 'rev-list', ' ancestry-path',
                            '%s..%s' % (oldCommit.hexsha, newCommit.hexsha)]).split()

当然,oldCommit和{}是git.Commit对象。在

相关问题 更多 >