summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorEdward Zhang <45360012+edwardzhanged@users.noreply.github.com>2024-04-17 21:24:07 +0800
committerGitHub <noreply@github.com>2024-04-17 15:24:07 +0200
commit02e183bf3fa502b7cef76e8dcdbf01b85ce641f0 (patch)
treefd1cf41f17ecf505982a369a30d448efefd49921 /routers
parent0798370f25ca3bd67933dd6d75c342aaded57095 (diff)
downloadgitea-02e183bf3fa502b7cef76e8dcdbf01b85ce641f0.tar.gz
gitea-02e183bf3fa502b7cef76e8dcdbf01b85ce641f0.zip
Fix branch_protection api shows users/teams who has no readAccess (#30291)
Add some logic in `convert.ToBranchProtection` to return only the names associated with readAccess instead of returning all names. This will ensure consistency in behavior between the frontend and backend. Fixes: #27694 --------- Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: wenzhuo.zhang <wenzhuo.zhang@geely.com> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/branch.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go
index 5e6b6a8658..baab486e52 100644
--- a/routers/api/v1/repo/branch.go
+++ b/routers/api/v1/repo/branch.go
@@ -437,7 +437,7 @@ func GetBranchProtection(ctx *context.APIContext) {
return
}
- ctx.JSON(http.StatusOK, convert.ToBranchProtection(ctx, bp))
+ ctx.JSON(http.StatusOK, convert.ToBranchProtection(ctx, bp, repo))
}
// ListBranchProtections list branch protections for a repo
@@ -470,7 +470,7 @@ func ListBranchProtections(ctx *context.APIContext) {
}
apiBps := make([]*api.BranchProtection, len(bps))
for i := range bps {
- apiBps[i] = convert.ToBranchProtection(ctx, bps[i])
+ apiBps[i] = convert.ToBranchProtection(ctx, bps[i], repo)
}
ctx.JSON(http.StatusOK, apiBps)
@@ -681,7 +681,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
return
}
- ctx.JSON(http.StatusCreated, convert.ToBranchProtection(ctx, bp))
+ ctx.JSON(http.StatusCreated, convert.ToBranchProtection(ctx, bp, repo))
}
// EditBranchProtection edits a branch protection for a repo
@@ -959,7 +959,7 @@ func EditBranchProtection(ctx *context.APIContext) {
return
}
- ctx.JSON(http.StatusOK, convert.ToBranchProtection(ctx, bp))
+ ctx.JSON(http.StatusOK, convert.ToBranchProtection(ctx, bp, repo))
}
// DeleteBranchProtection deletes a branch protection for a repo