API support for listing tags and fetching tag details #1164

Closed
opened 2025-11-02 03:50:53 -06:00 by GiteaMirror · 30 comments
Owner

Originally created by @stephenc on GitHub (Oct 18, 2017).

Originally assigned to: @lafriks on GitHub.

Description

The API currently exposes details of branches and pull requests but does not allow discovering tags.

The minimum support that I would like to see:

  • A way to get a list of all tags in a repository, e.g. /api/v1/repos/${repoOwner}/${repoName}/tags
  • A way to get a specific tag, e.g. /api/v1/repos/${repoOwner}/${repoName}/tags/${tagName}
  • Push event notification on creation of tags (if not already present)

The tag JSON object should probably have the following structure:

  • lightweight tags (i.e. where the tag refers to a commit):

    {
      name: "v1.0.0",
      commit: {
        id: "...",
        message: "...",
        url: "...",
        author: {
          name: "...",
          email: "...",
          username: "..."
        },
        committer: {
          name: "...",
          email: "...",
          username: "..."
        },
        verification: {
          verified: false,
          reason: "gpg.error.not_signed_commit",
          signature: "",
          payload: ""
        },
        timestamp: "2017-08-31T19:26:04Z"
      }
    }
    
  • annotated tags (i.e. where the tag is an object referencing the commit):

    {
      name: "v1.0.0",
      tag: {
        id: "...",
        message: "...",
        url: "...",
        author: {
          name: "...",
          email: "...",
          username: "..."
        },
        committer: {
          name: "...",
          email: "...",
          username: "..."
        },
        verification: {
          verified: false,
          reason: "gpg.error.not_signed_commit",
          signature: "",
          payload: ""
        },
        timestamp: "2017-08-31T19:26:04Z",
        commit: {
          id: "...",
          message: "...",
          url: "...",
          author: {
            name: "...",
            email: "...",
            username: "..."
          },
          committer: {
            name: "...",
            email: "...",
            username: "..."
          },
          verification: {
            verified: false,
            reason: "gpg.error.not_signed_commit",
            signature: "",
            payload: ""
          },
          timestamp: "2017-08-31T19:26:04Z"
        }
      }
    }
    
Originally created by @stephenc on GitHub (Oct 18, 2017). Originally assigned to: @lafriks on GitHub. ## Description The API currently exposes details of branches and pull requests but does not allow discovering tags. The minimum support that I would like to see: * A way to get a list of all tags in a repository, e.g. `/api/v1/repos/${repoOwner}/${repoName}/tags` * A way to get a specific tag, e.g. `/api/v1/repos/${repoOwner}/${repoName}/tags/${tagName}` * Push event notification on creation of tags (if not already present) The tag JSON object should probably have the following structure: * lightweight tags (i.e. where the tag refers to a commit): ``` { name: "v1.0.0", commit: { id: "...", message: "...", url: "...", author: { name: "...", email: "...", username: "..." }, committer: { name: "...", email: "...", username: "..." }, verification: { verified: false, reason: "gpg.error.not_signed_commit", signature: "", payload: "" }, timestamp: "2017-08-31T19:26:04Z" } } ``` * annotated tags (i.e. where the tag is an object referencing the commit): ``` { name: "v1.0.0", tag: { id: "...", message: "...", url: "...", author: { name: "...", email: "...", username: "..." }, committer: { name: "...", email: "...", username: "..." }, verification: { verified: false, reason: "gpg.error.not_signed_commit", signature: "", payload: "" }, timestamp: "2017-08-31T19:26:04Z", commit: { id: "...", message: "...", url: "...", author: { name: "...", email: "...", username: "..." }, committer: { name: "...", email: "...", username: "..." }, verification: { verified: false, reason: "gpg.error.not_signed_commit", signature: "", payload: "" }, timestamp: "2017-08-31T19:26:04Z" } } } ```
GiteaMirror added the type/featureissue/criticalmodifies/api labels 2025-11-02 03:50:53 -06:00
Author
Owner

@bkcsoft commented on GitHub (Nov 1, 2017):

https://developer.github.com/v3/git/tags/

@bkcsoft commented on GitHub (Nov 1, 2017): https://developer.github.com/v3/git/tags/
Author
Owner

@stephenc commented on GitHub (Nov 1, 2017):

note that on github's api, it is undocumented, but GET /repos/:owner/:repo/git/tags will return a paged list of tags.

as long as there is a way to get a list of tags, get a tag by name and get push notification of tags then I can implement https://github.com/jenkinsci/gitea-plugin/pull/6

@stephenc commented on GitHub (Nov 1, 2017): note that on github's api, it is undocumented, but `GET /repos/:owner/:repo/git/tags` will return a paged list of tags. as long as there is a way to get a list of tags, get a tag by name and get push notification of tags then I can implement https://github.com/jenkinsci/gitea-plugin/pull/6
Author
Owner

@stephenc commented on GitHub (Dec 18, 2017):

@lafriks any ETA?

@stephenc commented on GitHub (Dec 18, 2017): @lafriks any ETA?
Author
Owner

@lafriks commented on GitHub (Dec 18, 2017):

sorry, currently no one is on this at the moment but we are one step closer to this as all tag data are already in database so this should be easy enough to implement.

@lafriks commented on GitHub (Dec 18, 2017): sorry, currently no one is on this at the moment but we are one step closer to this as all tag data are already in database so this should be easy enough to implement.
Author
Owner

@tgulacsi commented on GitHub (Feb 25, 2018):

This got serious: the new vgo experiment needs an API to parse versions (https://godoc.org/golang.org/x/vgo/vendor/cmd/go/internal/modfetch#Repo), so this will be required.

Any directions? Which API endpoint should we start copying for this?

@tgulacsi commented on GitHub (Feb 25, 2018): This got serious: the new [vgo](golang.org/x/vgo) experiment needs an API to parse versions (https://godoc.org/golang.org/x/vgo/vendor/cmd/go/internal/modfetch#Repo), so this will be required. Any directions? Which API endpoint should we start copying for this?
Author
Owner

@lunny commented on GitHub (Feb 25, 2018):

@tgulacsi vgo will be released at least about six month I think. Maybe we have enough time to resolve this issue if someone would like to send a PR.

@lunny commented on GitHub (Feb 25, 2018): @tgulacsi `vgo` will be released at least about six month I think. Maybe we have enough time to resolve this issue if someone would like to send a PR.
Author
Owner

@tgulacsi commented on GitHub (Feb 25, 2018):

I'd like to help, just point me in the right direction. An API endpoint to
copy would be a good start.

Lunny Xiao notifications@github.com ezt írta (időpont: 2018. febr. 25.,
V, 14:45):

@tgulacsi https://github.com/tgulacsi vgo will be released at least
about six month I think. Maybe we have enough time to resolve this issue if
someone would like to send a PR.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/go-gitea/gitea/issues/2738#issuecomment-368310610,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAPoSpWNHY64xTab2yI95yxNAujX8mndks5tYWQHgaJpZM4P-fRm
.

@tgulacsi commented on GitHub (Feb 25, 2018): I'd like to help, just point me in the right direction. An API endpoint to copy would be a good start. Lunny Xiao <notifications@github.com> ezt írta (időpont: 2018. febr. 25., V, 14:45): > @tgulacsi <https://github.com/tgulacsi> vgo will be released at least > about six month I think. Maybe we have enough time to resolve this issue if > someone would like to send a PR. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/go-gitea/gitea/issues/2738#issuecomment-368310610>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAPoSpWNHY64xTab2yI95yxNAujX8mndks5tYWQHgaJpZM4P-fRm> > . >
Author
Owner

@sapk commented on GitHub (Feb 25, 2018):

You can look at merged PR related to API : https://github.com/go-gitea/gitea/pulls?utf8=%E2%9C%93&q=is%3Apr+label%3Akind%2Fapi+is%3Aclosed+

@sapk commented on GitHub (Feb 25, 2018): You can look at merged PR related to API : https://github.com/go-gitea/gitea/pulls?utf8=%E2%9C%93&q=is%3Apr+label%3Akind%2Fapi+is%3Aclosed+
Author
Owner

@sapk commented on GitHub (Feb 25, 2018):

For example a simple API added endpoint : https://github.com/go-gitea/gitea/pull/2047
You may need to update the sdk (https://github.com/go-gitea/go-sdk) before like in #1668 with https://github.com/go-gitea/go-sdk/pull/56

@sapk commented on GitHub (Feb 25, 2018): For example a simple API added endpoint : https://github.com/go-gitea/gitea/pull/2047 You may need to update the sdk (https://github.com/go-gitea/go-sdk) before like in #1668 with https://github.com/go-gitea/go-sdk/pull/56
Author
Owner

@tgulacsi commented on GitHub (Feb 25, 2018):

PTAL on https://github.com/tgulacsi/gitea/tree/api-tags esp. https://github.com/tgulacsi/gitea/blob/api-tags/models/tag.go - it compiles, but that's all. I don't know how should I test it, or whether it is moderately acceptable at all.
What about the paths? (/repos/:id/tags)
Now it is only to list tags, as Release already embodies a tag, so it is not clear how these two should live together...

@tgulacsi commented on GitHub (Feb 25, 2018): PTAL on https://github.com/tgulacsi/gitea/tree/api-tags esp. https://github.com/tgulacsi/gitea/blob/api-tags/models/tag.go - it compiles, but that's all. I don't know how should I test it, or whether it is moderately acceptable at all. What about the paths? (/repos/:id/tags) Now it is only to list tags, as Release already embodies a tag, so it is not clear how these two should live together...
Author
Owner

@sapk commented on GitHub (Feb 25, 2018):

For design of path and response format we generally try to follow github format for compat. For testing try to write integrations tests like in #2047 and try to run them with https://github.com/go-gitea/gitea/tree/master/integrations#integrations-tests. When you start to have something working submit a PR so that we can review it.

@sapk commented on GitHub (Feb 25, 2018): For design of path and response format we generally try to follow github format for compat. For testing try to write integrations tests like in #2047 and try to run them with https://github.com/go-gitea/gitea/tree/master/integrations#integrations-tests. When you start to have something working submit a PR so that we can review it.
Author
Owner

@stephenc commented on GitHub (Jul 10, 2018):

ping!

@stephenc commented on GitHub (Jul 10, 2018): ping!
Author
Owner

@stephenc commented on GitHub (Sep 4, 2018):

Ping!

@stephenc commented on GitHub (Sep 4, 2018): Ping!
Author
Owner

@tgulacsi commented on GitHub (Sep 5, 2018):

github.com/gomods/athens works as a GOPROXY and no need for the go mod
specific API.

Stephen Connolly notifications@github.com ezt írta (időpont: 2018. szept.
4., K, 22:55):

Ping!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/go-gitea/gitea/issues/2738#issuecomment-418514791,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAPoSvspSzxosW0ktJpIp0nn09u9iwgeks5uXujWgaJpZM4P-fRm
.

@tgulacsi commented on GitHub (Sep 5, 2018): github.com/gomods/athens works as a GOPROXY and no need for the go mod specific API. Stephen Connolly <notifications@github.com> ezt írta (időpont: 2018. szept. 4., K, 22:55): > Ping! > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/go-gitea/gitea/issues/2738#issuecomment-418514791>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAPoSvspSzxosW0ktJpIp0nn09u9iwgeks5uXujWgaJpZM4P-fRm> > . >
Author
Owner

@stephenc commented on GitHub (Sep 5, 2018):

@thulacsi I suspect you don’t understand what this ticket is looking for as your answer does not make any sense to me. What has GOPROXY got to do with an API exposed in the gitea webapp that allows listing the git tags in a git repo hosted on a gitea server?

@stephenc commented on GitHub (Sep 5, 2018): @thulacsi I suspect you don’t understand what this ticket is looking for as your answer does not make any sense to me. What has GOPROXY got to do with an API exposed in the gitea webapp that allows listing the git tags in a git repo hosted on a gitea server?
Author
Owner

@lunny commented on GitHub (Sep 11, 2018):

@stephenc so, but why close this one?

@lunny commented on GitHub (Sep 11, 2018): @stephenc so, but why close this one?
Author
Owner

@stephenc commented on GitHub (Sep 11, 2018):

@lunny sorry hit wrong button... thanks for pointing out

@stephenc commented on GitHub (Sep 11, 2018): @lunny sorry hit wrong button... thanks for pointing out
Author
Owner

@lafriks commented on GitHub (Nov 18, 2018):

@stephenc I started implementing with GitHub compatible Git Refs API routes and objects

@lafriks commented on GitHub (Nov 18, 2018): @stephenc I started implementing with GitHub compatible Git Refs API routes and objects
Author
Owner

@stephenc commented on GitHub (Nov 18, 2018):

@stephenc commented on GitHub (Nov 18, 2018): ![](https://media.giphy.com/media/3o6Yg1srxZ0lQYUFj2/giphy.gif)
Author
Owner

@lafriks commented on GitHub (Nov 27, 2018):

Tag list is now implemented using refs API, still missing getting tags details

@lafriks commented on GitHub (Nov 27, 2018): Tag list is now implemented using refs API, still missing getting tags details
Author
Owner

@lafriks commented on GitHub (Dec 27, 2018):

Getting tag details will be in 1.8.0, so I'm moving issue to that milestone

@lafriks commented on GitHub (Dec 27, 2018): Getting tag details will be in 1.8.0, so I'm moving issue to that milestone
Author
Owner

@lunny commented on GitHub (Feb 28, 2019):

@lafriks since there is no PR for this, let's move this to 1.9.0

@lunny commented on GitHub (Feb 28, 2019): @lafriks since there is no PR for this, let's move this to 1.9.0
Author
Owner

@conradoqg commented on GitHub (Apr 26, 2019):

Is someone working on this?

@conradoqg commented on GitHub (Apr 26, 2019): Is someone working on this?
Author
Owner

@stephenc commented on GitHub (Apr 26, 2019):

I hope so because the fully polished Jenkins plugin is dependent on this

@stephenc commented on GitHub (Apr 26, 2019): I hope so because the fully polished Jenkins plugin is dependent on this
Author
Owner

@lafriks commented on GitHub (Apr 26, 2019):

Listing is done, I'm working on details

@lafriks commented on GitHub (Apr 26, 2019): Listing is done, I'm working on details
Author
Owner

@richmahn commented on GitHub (May 31, 2019):

@stephenc Is it wanting /api/v1/repos/${repoOwner}/${repoName}/tags/${tagName} or /api/v1/repos/${repoOwner}/${repoName}/git/tags/${tagName} ? GitHub has /repos/${repoOwner}/${repoName}/tags and then you have to change /tags to /git/tags/{$tagSHA}. There is also /git/refs and /git/refs/tags/<$tagSHA> so wondering what exactly Jenkins is looking for.

@richmahn commented on GitHub (May 31, 2019): @stephenc Is it wanting /api/v1/repos/${repoOwner}/${repoName}/tags/${tagName} or /api/v1/repos/${repoOwner}/${repoName}/git/tags/${tagName} ? GitHub has /repos/${repoOwner}/${repoName}/tags and then you have to change `/tags` to `/git/tags/{$tagSHA}`. There is also `/git/refs` and `/git/refs/tags/<$tagSHA>` so wondering what exactly Jenkins is looking for.
Author
Owner

@richmahn commented on GitHub (May 31, 2019):

I'm now working on the details for tags.

@richmahn commented on GitHub (May 31, 2019): I'm now working on the details for tags.
Author
Owner

@stephenc commented on GitHub (May 31, 2019):

So right now we have this API to list the tags:

Screenshot 2019-05-31 at 16 47 00

The /repos/{owner}/{repo}/git/refs/{ref} path doesn't return an object with the details we require

Screenshot 2019-05-31 at 16 53 45

Namely it doesn't supply the details of the timestamp of the tag object or enable differentiation between annotated tags and lightweight tags.

If I look at the GitHub API, https://developer.github.com/v3/git/tags/ provides the details we need. I think what you want is to implement a route equivalent to the github one, namely /repos/{owner}/{repo}/git/tags/{tag}. This route would only support annotated tag objects, so if it returns a failure then we can conclude that the object is a lightweight tag!

Once we have /repos/{owner}/{repo}/git/tags/{tag} then we are good.

Now having said all that, if I wasn't interested in matching closely the github api, then I might separate the routes differently and have the tags route return the rich objects... but as I understand it, mirroring the GitHub API structure is valued by Gitea, so in that case /repos/{owner}/{repo}/git/tags/{tag} is all that remains

@stephenc commented on GitHub (May 31, 2019): So right now we have this API to list the tags: <img width="1437" alt="Screenshot 2019-05-31 at 16 47 00" src="https://user-images.githubusercontent.com/209336/58717739-d4966c00-83c3-11e9-93e2-0aa519c59a55.png"> The `/repos/{owner}/{repo}/git/refs/{ref}` path doesn't return an object with the details we require <img width="1435" alt="Screenshot 2019-05-31 at 16 53 45" src="https://user-images.githubusercontent.com/209336/58718189-e88e9d80-83c4-11e9-81ee-e306a394d670.png"> Namely it doesn't supply the details of the timestamp of the tag object or enable differentiation between annotated tags and lightweight tags. If I look at the GitHub API, https://developer.github.com/v3/git/tags/ provides the details we need. I think what you want is to implement a route equivalent to the github one, namely `/repos/{owner}/{repo}/git/tags/{tag}`. This route would only support annotated tag objects, so if it returns a failure then we can conclude that the object is a lightweight tag! Once we have `/repos/{owner}/{repo}/git/tags/{tag}` then we are good. Now having said all that, if I wasn't interested in matching closely the github api, then I might separate the routes differently and have the tags route return the rich objects... but as I understand it, mirroring the GitHub API structure is valued by Gitea, so in that case `/repos/{owner}/{repo}/git/tags/{tag}` is all that remains
Author
Owner

@richmahn commented on GitHub (Jun 5, 2019):

@stephenc That's for your response! Actually just figured out myself, before reading your reply, that git/refs/tags does not distinguish between lightweight (commit) tags and annotated (tag) tags. So I have already change that in my work on this.

@richmahn commented on GitHub (Jun 5, 2019): @stephenc That's for your response! Actually just figured out myself, before reading your reply, that git/refs/tags does not distinguish between lightweight (commit) tags and annotated (tag) tags. So I have already change that in my work on this.
Author
Owner

@richmahn commented on GitHub (Jun 6, 2019):

@stephenc See my PR above. Should have everything you specified, with /git/tags/{sha} only working for annotated tags.

@richmahn commented on GitHub (Jun 6, 2019): @stephenc See my PR above. Should have everything you specified, with /git/tags/{sha} only working for annotated tags.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1164