当我使用 GitPython 尝试以下代码时:
repo.head.commit.diff('HEAD~1')[0].diff
它总是返回一个空字符串。我在不同的提交中也尝试过多次更改文件。
我还尝试了以下代码,该代码将列出第一次和最后一次提交之间的所有更改文件。
changed_files = []
for x in commits_list[0].diff(commits_list[-1]):
if x.a_blob.path not in changed_files:
changed_files.append(x.a_blob.path)
if x.b_blob is not None and x.b_blob.path not in changed_files:
changed_files.append(x.b_blob.path)
print changed_files