Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API support for listing tags and fetching tag details #2738

Closed
stephenc opened this issue Oct 18, 2017 · 30 comments · Fixed by #5354 or #7138
Closed

API support for listing tags and fetching tag details #2738

stephenc opened this issue Oct 18, 2017 · 30 comments · Fixed by #5354 or #7138
Assignees
Labels
issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP modifies/api This PR adds API routes or modifies them type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Milestone

Comments

@stephenc
Copy link

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"
        }
      }
    }
    
@lafriks lafriks added modifies/api This PR adds API routes or modifies them type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Oct 19, 2017
@lafriks lafriks added this to the 1.x.x milestone Oct 19, 2017
@bkcsoft
Copy link
Member

bkcsoft commented Nov 1, 2017

@stephenc
Copy link
Author

stephenc commented 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 jenkinsci/gitea-plugin#6

@stephenc
Copy link
Author

@lafriks any ETA?

@lafriks
Copy link
Member

lafriks commented 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.

@tgulacsi
Copy link

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?

@lunny
Copy link
Member

lunny commented 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.

@tgulacsi
Copy link

tgulacsi commented Feb 25, 2018 via email

@sapk
Copy link
Member

sapk commented Feb 25, 2018

@sapk
Copy link
Member

sapk commented Feb 25, 2018

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

@tgulacsi
Copy link

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...

@sapk
Copy link
Member

sapk commented 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.

@stephenc

This comment has been minimized.

@stephenc

This comment has been minimized.

@tgulacsi
Copy link

tgulacsi commented Sep 5, 2018 via email

@stephenc
Copy link
Author

stephenc commented 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 stephenc closed this as completed Sep 5, 2018
@lunny
Copy link
Member

lunny commented Sep 11, 2018

@stephenc so, but why close this one?

@stephenc
Copy link
Author

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

@stephenc stephenc reopened this Sep 11, 2018
@lafriks lafriks added the issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP label Sep 27, 2018
@lafriks lafriks modified the milestones: 1.x.x, 1.7.0 Sep 27, 2018
@lafriks lafriks self-assigned this Sep 27, 2018
@lafriks
Copy link
Member

lafriks commented Nov 18, 2018

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

@stephenc

This comment has been minimized.

@lafriks
Copy link
Member

lafriks commented Nov 27, 2018

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

@lafriks lafriks modified the milestones: 1.7.0, 1.8.0 Dec 27, 2018
@lafriks
Copy link
Member

lafriks commented Dec 27, 2018

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

@lunny
Copy link
Member

lunny commented Feb 28, 2019

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

@conradoqg
Copy link

Is someone working on this?

@stephenc
Copy link
Author

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

@lafriks
Copy link
Member

lafriks commented Apr 26, 2019

Listing is done, I'm working on details

@richmahn
Copy link
Contributor

@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
Copy link
Contributor

I'm now working on the details for tags.

@stephenc
Copy link
Author

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

@techknowlogick techknowlogick modified the milestones: 1.9.0, 1.10.0 Jun 4, 2019
@richmahn
Copy link
Contributor

richmahn commented 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 added a commit to richmahn/gitea that referenced this issue Jun 5, 2019
@richmahn
Copy link
Contributor

richmahn commented Jun 6, 2019

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

@techknowlogick techknowlogick modified the milestones: 1.10.0, 1.9.0 Jun 8, 2019
lafriks pushed a commit that referenced this issue Jun 8, 2019
* Fixes #2738 - /git/tags API

* proper URLs

* Adds function comments

* Updates swagger

* Removes newline from tag message

* Removes trailing newline from commit message

* Adds integration test

* Removed debugging

* Adds tests

* Fixes bug where multiple tags of same commit show wrong tag name

* Fix formatting

* Removes unused varaible

* Fix to annotated tag function names and response

* Update modules/git/repo_tag.go

Co-Authored-By: Lauris BH <lauris@nix.lv>

* Uses TagPrefix

* Changes per review, better error handling for getting tag and commit IDs

* Fix to getting commit ID

* Fix to getting commit ID

* Fix to getting commit ID

* Fix to getting commit ID
jeffliu27 pushed a commit to jeffliu27/gitea that referenced this issue Jul 18, 2019
* Fixes go-gitea#2738 - /git/tags API

* proper URLs

* Adds function comments

* Updates swagger

* Removes newline from tag message

* Removes trailing newline from commit message

* Adds integration test

* Removed debugging

* Adds tests

* Fixes bug where multiple tags of same commit show wrong tag name

* Fix formatting

* Removes unused varaible

* Fix to annotated tag function names and response

* Update modules/git/repo_tag.go

Co-Authored-By: Lauris BH <lauris@nix.lv>

* Uses TagPrefix

* Changes per review, better error handling for getting tag and commit IDs

* Fix to getting commit ID

* Fix to getting commit ID

* Fix to getting commit ID

* Fix to getting commit ID
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP modifies/api This PR adds API routes or modifies them type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
9 participants