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) }