2 years ago
#34560
Mohammad Shakib
How to get time of last commit date for Git repository files via Python?
I'm trying to get the latest commit date for each file in a specific folder in a repo.
My code:
import git
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
repo = git.Repo(dir_path)
tree = repo.tree()
for blob in tree.trees[1]:
print(blob.name)
# print(blob.path)
commit = repo.iter_commits(paths=blob.name, max_count=100).next()
print(commit.committed_date)
Error I'm getting:
Traceback (most recent call last):
File "d:\Coding\Temp\get_commit_date.py", line 12, in <module>
commit = repo.iter_commits(paths=blob.name, max_count=1).next()
AttributeError: 'generator' object has no attribute 'next'
Is there any way to make this code work?
python
python-3.x
gitpython
0 Answers
Your Answer