Skip to content

Instantly share code, notes, and snippets.

@multimeric
Created September 25, 2020 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save multimeric/32bcf951036499790863cf6e310900e0 to your computer and use it in GitHub Desktop.
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
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