Skip to content

Get commit time of each File in tree #1368

@dsharma522

Description

@dsharma522

There is no way to get the commit time of a FILE in the tree , as something we can get via command

git log -1 --pretty="format:%cI" <file_path>

repo = git.Repo('some_repo')
tree = repo.tree().traverse()
for blob in tree:
    print(blob.path)
    if os.path.isfile(blob.abspath):
       # get commit_time of blob something like 'git log -1 --pretty="format:%cI" blob.path'
       pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions