mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	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>
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user