git: is it possible to see remote tags with annotations without cloning?

Viewed 204

I would like to see remote tags, with annotations, without downloading anything.

I know I can see remote tags with e.g. git ls-remote --tags origin, but this does not show the annotations.

I also know that I can see annotations with e.g. git tag -n, but this would require to fetch the tags before.

Is there a way to accomplish this?

2 Answers

For Azure DevOps, you can indeed use the API to:

1/ List tags

GET https://dev.azure.com/fabrikam/_apis/git/repositories/{repositoryId}/refs?filter=tags/&api-version=6.0

That will get you their objectId

2/ For each tag object Id, query the annotated tag itself

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/annotatedtags/{objectId}?api-version=6.0-preview.1

You will get a GitAnnotatedTag, which includes message: The tagging Message.

Well, you have to download at least the tag annotations, right? Those are in the annotated tags, and you can pretty sharply restrict your fetch filter. Easiest is just --filter=blob:none, but if the server supports it (github doesn't yet) you can really clamp down on the fetch traffic with --filter=combine:blob:none+tree:0.

Anyway, one that doesn't ask more than github has so far implemented is

git init `mktemp -d`
cd $_
git fetch --filter=tree:0 u://r/l
git rev-list --tags --no-walk | git cat-file --batch

As @VonC points out, anyone can provide any web (or other tranpsort) frontend they want on a repo and provide an interface to whatever they care to provide. Git's not about providing web interfaces to remote data, it's about getting the data local so you can have your way with it.

Related