如何使用pydriller在Git repo中查找新添加的文件



我能够找到在Git repo中修改过的文件,但这段代码没有返回新添加的文件,有人能帮我更新代码吗,以便识别新添加的文档。

from pydriller import Repository
for commit in Repository('path/to/the/repo').traverse_commits():
for m in commit.modified_files:
print("Modified file {}".format(m.filename))

例如,在commit1和commit5之间,有3个文件被修改,2个新添加的

M       changelog1.txt
M       newfile2.txt
M       changelog3.txt
A       changelog4.txt
A       newfile5.txt

使用上面的代码,它将返回所有已修改的文件,但不返回已添加的文件。

附言:我也对任何其他解决方案持开放态度

添加和修改两个文件都由Repository('path/to/the/repo').traverse_commits():拾取

为了查看修改后的文件的状态,我们只需要使用m.change_type,如以下示例中所述

print("File {} change_type {}".format(m.filename, m.change_type)

最新更新