aboutsummaryrefslogtreecommitdiff
path: root/internal/route/api/v1/repo
diff options
context:
space:
mode:
authorDevops <943927833@qq.com>2021-12-14 20:41:12 +0800
committerGitHub <noreply@github.com>2021-12-14 20:41:12 +0800
commitd60d9cf9857d1e7a7915b62851b254a5304b6cdc (patch)
tree3a8f0acbf46b32dd825563386c0d678a7a7c8e76 /internal/route/api/v1/repo
parent63bd4bb4b1de84592059e61411ee65877de16bb8 (diff)
api: support listing repository tags (#6656)
Co-authored-by: zhouzhibo <zhouzhibo> Co-authored-by: Joe Chen <jc@unknwon.io>
Diffstat (limited to 'internal/route/api/v1/repo')
-rw-r--r--internal/route/api/v1/repo/tag.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/route/api/v1/repo/tag.go b/internal/route/api/v1/repo/tag.go
new file mode 100644
index 00000000..73b7e064
--- /dev/null
+++ b/internal/route/api/v1/repo/tag.go
@@ -0,0 +1,30 @@
+// Copyright 2021 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package repo
+
+import (
+ "gogs.io/gogs/internal/context"
+ "gogs.io/gogs/internal/route/api/v1/convert"
+)
+
+func ListTags(c *context.APIContext) {
+ tags, err := c.Repo.Repository.GetTags()
+ if err != nil {
+ c.Error(err, "get tags")
+ return
+ }
+
+ apiTags := make([]*convert.Tag, len(tags))
+ for i := range tags {
+ commit, err := tags[i].GetCommit()
+ if err != nil {
+ c.Error(err, "get commit")
+ return
+ }
+ apiTags[i] = convert.ToTag(tags[i], commit)
+ }
+
+ c.JSONSuccess(&apiTags)
+}