shields
shields copied to clipboard
Badge request: GitHub last commit to any branch
:clipboard: Description A badge for github which show the time for the last commit to any branch.
This is what I expected that the "GitHub last commit" badge would do, but it only checks the master branch.
:link: Data I would hope that there is a similar solution as the already existing github badges, but I have no experience in querying github for such data.
:microphone: Motivation
For some projects the master branch will only update when there is a new release, which might be much more infrequent than any commits. I found out that this badge was not really existing when I wanted a "last commit" badge and a "last release" badge. For my repo I can create the "last release" badge for my repo by pointing the current "last commit" badge to the master branch and using a custom label. Similarly, it's possible to get the last commit to any specific branch, but not the last commit to the repo as a whole.
I suspect this is actually pretty hard to work out in a single request, but perhaps someone is able to concoct a suitably fiendish GraphQL query? One of the issues is that it isn't possible to order refs (branches) by the last commit date https://docs.github.com/en/graphql/reference/enums#reforderfield so I think we'd have to at least iterate and page over (max 100 per page) every branch to find the most recently updated branch and then get the head commit for that branch.
I browsed the docs that you linked a bit and found some stuff that might be useful.
- The Repository object (https://docs.github.com/en/graphql/reference/objects#repository) has a
pushedAt
field, which is supposed to describe when the repo was last pushed to. This could be a reasonable proxy if it takes into account all the branches and not just the master branch. - There's also a list of
refs
in the Repository, which can be sorted usingorderBy
, but that might be what you referred to earlier?
Unfortunately, I'm of no use other than poking these kinds of lists. I don't really know what GraphQL is or how to use it...
but that might be what you referred to earlier?
Yeah exactly - there's an orderBy
param but the only allowable values for it are ALPHABETICAL
and TAG_COMMIT_DATE
pushedAt
sounds exactly like what I am searching for as well!
Alternatively I would be happy with a 'last commit to default branch', since master is not the standard anymore