Home > Software design >  How can I get the last commit date of a GitLab Repo in Python
How can I get the last commit date of a GitLab Repo in Python

Time:08-01

I'm searching a way how I get the last commit date of a Repo via Python.

gl.auth()
project = gl.projects.get('paulsner_lars/Test')

CodePudding user response:

If you list the commits, the most recent commit will be the first commit returned.

most_recent_commit, = project.commits.list(per_page=1)
print(most_recent_commit.committed_date)

However, keep in mind that commit dates are arbitrary and can be set by the committer. If you want to reliably know the last activity on the repo, use project.last_activity_at or project.events.list instead.

  • Related