From d101c834d82afdf15cd819b42f38b8a13ce0f21d Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 21 Mar 2023 18:16:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E8=BF=94=E5=9B=9E=E7=A9=BA=E6=95=B0=E7=BB=84?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E5=88=86=E6=94=AF=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/hat/repo/branch.go | 2 +- routers/hat/repo/tag.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/routers/hat/repo/branch.go b/routers/hat/repo/branch.go index f160983..ca856dd 100644 --- a/routers/hat/repo/branch.go +++ b/routers/hat/repo/branch.go @@ -19,7 +19,7 @@ import ( ) func ListBranches(ctx *context.APIContext) { - searchName := ctx.Params("name") + searchName := ctx.FormString("name") listOptions := utils.GetListOptions(ctx) skip, _ := listOptions.GetStartEnd() branches, totalNumOfBranches, err := hat_git.GetSearchBranches(ctx, ctx.Repo.GitRepo, searchName, skip, listOptions.PageSize) diff --git a/routers/hat/repo/tag.go b/routers/hat/repo/tag.go index f92f23d..a0a88dd 100644 --- a/routers/hat/repo/tag.go +++ b/routers/hat/repo/tag.go @@ -98,18 +98,18 @@ func TagNameSet(ctx *context.APIContext) { return } - if searchName == "" { - ctx.JSON(http.StatusOK, tags) - } else { - var tagNameSet []string - for _, tag := range tags { + var tagNameSet = make([]string, 0) - log.Info("tag is \n", tag) + for _, tag := range tags { + log.Info("tag is \n", tag) + if searchName != "" { if strings.Contains(tag, searchName) { tagNameSet = append(tagNameSet, tag) } + } else { + tagNameSet = append(tagNameSet, tag) } - ctx.JSON(http.StatusOK, tagNameSet) } + ctx.JSON(http.StatusOK, tagNameSet) }