I have the following piece of code to get the list of commit summaries of a specific file:
from git import Repo
repo_working_dir = '<valid directory of the repo>'
repo = Repo(repo_working_dir)
update_file = '<full path of the file whose commit summaries I want to read>'
for commit in list(repo.iter_commits(repo.active_branch,paths=update_file)):
print(commit.summary)
The above code runs but returns no output. Please let me know where I am going wrong.
Repo.iter_commitsexpects a path relative to the git root, and is given a full path. In that case nothing would match and thus nothing would print resulting in no output. Documentation of gitpython does not clarify this at allrepo_working_dirbeing the (absolute) path to the root of my git repo"~/my_code/very_cool_project", andupdate_filebeing the (relative) path"README.md"repo.iter_commits(...)to a list, and it also could be causing your problem (converting the very heavy iterable created by this function to a list could take a long time if your commit list is very long)