修复:标签为空返回空数组,以及分支查询参数

This commit is contained in:
yystopf 2023-03-21 18:16:52 +08:00
parent ef95802907
commit d101c834d8
2 changed files with 8 additions and 8 deletions

View File

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

View File

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