我正在尝试访问单个文件的提交历史记录,如下所示:
git log --follow -- <filename>
我必须使用gitpython https://github.com/gitpython-developers/GitPython,所以我现在正在做的是:
import git
g = git.Git('repo_dir')
hexshas = g.log('--pretty=%H','--follow','--',filename).split('\n')
然后我构建提交对象:
repo = git.Repo('repo_dir')
commits = [repo.rev_parse(c) for c in r]
有没有办法以更 gitpython-ic 的方式做到这一点?
我都尝试过commit.iter_parents()
and commit.iter_items()
,但它们都依赖于git-rev-list
,所以他们没有--follow
option.
例如,
范围时间:
g = git.Git("C:/path/to/your/repo")
loginfo = g.log('--since=2013-09-01','--author=KIM BASINGER','--pretty=tformat:','--numstat')
print loginfo
Output:
3 2 path/in/your/solutions/some_file.cs
您可以看到添加的行、删除的行以及包含这些更改的文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)