修复:branch slice接口无法正常访问

This commit is contained in:
yystopf 2023-02-02 15:19:17 +08:00
parent a032635665
commit 9033d59c99
1 changed files with 8 additions and 8 deletions

View File

@ -17,7 +17,6 @@ import (
func ListBranchesSlice(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx)
skip, _ := listOptions.GetStartEnd()
branches, totalNumOfBranches, err := ctx.Repo.GitRepo.GetBranches(0, 0)
if err != nil {
@ -55,15 +54,16 @@ func ListBranchesSlice(ctx *context.APIContext) {
if branch.Name == ctx.Repo.Repository.DefaultBranch {
apiBranches[i].BranchKind = int(git.DefaultBranch)
}
sort.Sort(git.SortBranch(apiBranches))
branchSlice := paginate(apiBranches, skip, listOptions.Page)
BranchesSlice := BranchesSliceByProtection(ctx, branchSlice)
ctx.SetLinkHeader(int(totalNumOfBranches), listOptions.PageSize)
ctx.RespHeader().Set("X-Total-Count", fmt.Sprintf("%d", totalNumOfBranches))
ctx.RespHeader().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, &BranchesSlice)
}
sort.Sort(git.SortBranch(apiBranches))
BranchesSlice := BranchesSliceByProtection(ctx, apiBranches)
ctx.SetLinkHeader(int(totalNumOfBranches), listOptions.PageSize)
ctx.RespHeader().Set("X-Total-Count", fmt.Sprintf("%d", totalNumOfBranches))
ctx.RespHeader().Set("Access-Control-Expose-Headers", "X-Total-Count, Link")
ctx.JSON(http.StatusOK, &BranchesSlice)
}
func paginate(branchSlice []*git.Branch, skip, pageSize int) []*git.Branch {