0
我正在使用GitPython。下面我打印出一个具体的改变线的总数承诺:f092795fe94ba727f7368b63d8eb1ecd39749fc4
:GitPython“怪”并不会给我所有更改的行
from git import Repo
repo = Repo("C:/Users/shiro/Desktop/lucene-solr/")
sum_lines = 0
for blame_commit, lines_list in repo.blame('HEAD', 'lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java'):
if blame_commit.hexsha == 'f092795fe94ba727f7368b63d8eb1ecd39749fc4':
sum_lines += len(lines_list)
print sum_lines
输出为38.但是,如果你只是去https://github.com/apache/lucene-solr/commit/f092795fe94ba727f7368b63d8eb1ecd39749fc4,并期待在自己提交文件/lucene/analysis/Analyzer.java
,实际数量行改变不是38,但它是47.有些行完全缺失。
为什么我得到一个错误的值?
但是,那么我应该如何获得所有提交的第一个地方呢? – dimitris93
我想获得特定文件的所有{commit,lines-changed}信息 – dimitris93
_One_方法是迭代特定文件的“rev-list”中的所有提交。在git命令中,这将是'git rev-list master - some-file-here'。 GitPython通过'iter_commits'实现了这个功能: '用于提交repo.iter_commits(paths ='/ path/to/Analyzer.java'):...' –