Created
September 25, 2020 06:16
-
-
Save multimeric/32bcf951036499790863cf6e310900e0 to your computer and use it in GitHub Desktop.
Returns the last date of update of a file in a git repo as a unix timestamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
from git import Repo | |
def last_git_update(path: pathlib.Path) -> int: | |
""" | |
Returns the last date of update as a unix timestamp, according to a git repo | |
""" | |
repo = Repo(path.parent, search_parent_directories=True) | |
commit = next(repo.iter_commits(paths=path)) | |
return commit.authored_date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment