From cc050e9c195004926b0b5b790f9072f807ce6a7c Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 11 Dec 2023 08:49:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/hat/hat.go | 1 + routers/hat/repo/tag.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/routers/hat/hat.go b/routers/hat/hat.go index 539d108..115e0aa 100644 --- a/routers/hat/hat.go +++ b/routers/hat/hat.go @@ -79,6 +79,7 @@ func Routers(ctx gocontext.Context) *web.Route { }, context.ReferencesGitRepo(), reqRepoReader(unit.TypeCode)) m.Group("/tags", func() { m.Get("", repo.ListTags) + m.Get("/*", repo.GetTag) }, reqRepoReader(unit_model.TypeCode), context.ReferencesGitRepo(true)) m.Group("/wikies", func() { m.Combo("").Get(repo.ListWikiPages). diff --git a/routers/hat/repo/tag.go b/routers/hat/repo/tag.go index a0a88dd..260d4a0 100644 --- a/routers/hat/repo/tag.go +++ b/routers/hat/repo/tag.go @@ -44,6 +44,20 @@ func ListTags(ctx *context.APIContext) { ctx.JSON(http.StatusOK, &apiTags) } +func GetTag(ctx *context.APIContext) { + tagName := ctx.Params("*") + tag, err := ctx.Repo.GitRepo.GetTag(tagName) + if err != nil { + ctx.NotFound(tagName) + } + + apiTag, err := convert.ToTag(ctx.Repo.Repository, ctx.Repo.GitRepo, tag) + if err != nil { + ctx.Error(http.StatusInternalServerError, "hat_convert.ToTag", err) + } + ctx.JSON(http.StatusOK, apiTag) +} + func BranchTagCount(ctx *context.APIContext) { _, tagsTotal, err := ctx.Repo.GitRepo.GetTagInfos(0, 0) if err != nil {