I am using gitpython library for performing git operations, retrieve git info from python code. I want to retrieve all revisions for a specific file. But couldn't find a specific reference for this on the docs.
Can anybody give some clue on which function will help in this regard? Thanks.
A follow-on, to read each file:
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:
...
There is no such function, but it is easily implemented:
import git
repo = git.Repo()
path = "dir/file_you_are_looking_for"
commits_touching_path = list(repo.iter_commits(paths=path))
Performance will be moderate even if multiple paths are involved. Benchmarks and more code about that can be found in an issue on github.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With