Git The Last Commit Date from a GitHub Link using Github API

Viewed 67

I Have a specific Link that refer to a repo :

https://github.com/winkbrace/verlanglijstjes/blob/3d2ad6485254bb1fef52321248beab71103645f9/database/dump/verlanglijstjes.sql

The last commit was done on 27-Feb-2022

How can i get the last commit date using GitHub API syntax?

1 Answers

It can depend if you want the most recent commit from all the branches or only the default branch.

And if, by last commit date, you mean committer date, not author date.

In any case, start by installing GitHub CLI gh, and:

For the main branch:

gh api repos/git/git/commits/HEAD/branches-where-head --jq .[].commit.url
gh api repos/git/git/commits/715d08a9e51251ad8290b181b6ac3b9e1f9719d7 --jq .commit.committer.date
2022-02-25T23:47:38Z

In your case:

gh api repos/winkbrace/verlanglijstjes/commits/HEAD/branches-where-head --jq .[0].commit.url
https://api.github.com/repos/winkbrace/verlanglijstjes/commits/ccb174356ca35ace51dbaa2c34592b371b671436

And:

gh api repos/winkbrace/verlanglijstjes/commits/ccb174356ca35ace51dbaa2c34592b371b671436 --jq .commit.committer.date
2022-03-05T13:21:42Z
Related