Working with tags
List a repository's tags and understand annotated vs. lightweight tags.
tags.list / tags.listAll page through a repository’s tags as normalized Tag objects. Some providers
supply a tag date and annotation details — check capabilities.tagDates before relying on them.
Listing tags
tags.list returns one Page<Tag>; tags.listAll follows cursors and yields every tag. Both require a
repo:
const { data: tags } = await client.tags.list({ repo: 'capawesome-team/repo-sdk' });
for await (const tag of client.tags.listAll({ repo: 'capawesome-team/repo-sdk' })) {
console.log(tag.name, tag.sha);
}
The normalized Tag
name?string
The tag name (without the refs/tags/ prefix).
stringsha?string
The commit SHA the tag points at (annotated tags are peeled to the commit).
stringmessage?string
The tag message, for annotated tags.
stringdate?Date
The tag date — only when the provider supplies one (see below).
DateisAnnotated?boolean
Whether the tag is annotated rather than lightweight.
booleanraw?unknown
The untouched provider payload.
unknownTag dates are provider-dependent
if (client.capabilities.tagDates) {
for (const tag of tags) {
console.log(tag.name, tag.date); // a Date on GitLab/Bitbucket
}
}
isAnnotated distinguishes annotated tags (which carry their own object and message) from lightweight
tags. When available it’s derived from whether the provider returns an annotation for the tag.