没有这样的功能,但是很容易实现:
import git
repo = git.Repo()
path = "dir/file_you_are_looking_for"
commits_touching_path = list(repo.iter_commits(paths=path))
Run Code Online (Sandbox Code Playgroud)
即使涉及多个路径,性能也会适中。可以在github上的问题中找到基准和更多相关代码。
后续阅读每个文件:
import git
repo = git.Repo()
path = "file_you_are_looking_for"
revlist = (
(commit, (commit.tree / path).data_stream.read())
for commit in repo.iter_commits(paths=path)
)
for commit, filecontents in revlist:
...
Run Code Online (Sandbox Code Playgroud)