You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tag.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "code.gitea.io/gitea/modules/context"
  7. "code.gitea.io/gitea/routers/api/v1/convert"
  8. api "code.gitea.io/sdk/gitea"
  9. )
  10. // ListTags list all the tags of a repository
  11. func ListTags(ctx *context.APIContext) {
  12. // swagger:operation GET /repos/{owner}/{repo}/tags repository repoListTags
  13. // ---
  14. // summary: List a repository's tags
  15. // produces:
  16. // - application/json
  17. // parameters:
  18. // - name: owner
  19. // in: path
  20. // description: owner of the repo
  21. // type: string
  22. // required: true
  23. // - name: repo
  24. // in: path
  25. // description: name of the repo
  26. // type: string
  27. // required: true
  28. // responses:
  29. // "200":
  30. // "$ref": "#/responses/TagList"
  31. tags, err := ctx.Repo.Repository.GetTags()
  32. if err != nil {
  33. ctx.Error(500, "GetTags", err)
  34. return
  35. }
  36. apiTags := make([]*api.Tag, len(tags))
  37. for i := range tags {
  38. apiTags[i] = convert.ToTag(ctx.Repo.Repository, tags[i])
  39. }
  40. ctx.JSON(200, &apiTags)
  41. }