Skip to content

Commit 1c5c318

Browse files
committed
doer is never nil here.
1 parent d89861f commit 1c5c318

File tree

5 files changed

+5
-9
lines changed

5 files changed

+5
-9
lines changed

models/branches.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,7 @@ func (repo *Repository) GetBranchProtection(branchName string) (*ProtectedBranch
362362
}
363363

364364
// IsProtectedBranch checks if branch is protected
365-
func (repo *Repository) IsProtectedBranch(branchName string, doer *User) (bool, error) {
366-
if doer == nil {
367-
return true, nil
368-
}
369-
365+
func (repo *Repository) IsProtectedBranch(branchName string) (bool, error) {
370366
protectedBranch := &ProtectedBranch{
371367
RepoID: repo.ID,
372368
BranchName: branchName,

routers/api/v1/repo/branch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func DeleteBranch(ctx *context.APIContext) {
122122
return
123123
}
124124

125-
isProtected, err := ctx.Repo.Repository.IsProtectedBranch(branchName, ctx.User)
125+
isProtected, err := ctx.Repo.Repository.IsProtectedBranch(branchName)
126126
if err != nil {
127127
ctx.InternalServerError(err)
128128
return

routers/repo/branch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func DeleteBranchPost(ctx *context.Context) {
8989
return
9090
}
9191

92-
isProtected, err := ctx.Repo.Repository.IsProtectedBranch(branchName, ctx.User)
92+
isProtected, err := ctx.Repo.Repository.IsProtectedBranch(branchName)
9393
if err != nil {
9494
log.Error("DeleteBranch: %v", err)
9595
ctx.Flash.Error(ctx.Tr("repo.branch.deletion_failed", branchName))

routers/repo/issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ func ViewIssue(ctx *context.Context) {
14581458
}
14591459
if perm.CanWrite(models.UnitTypeCode) {
14601460
// Check if branch is not protected
1461-
if protected, err := pull.HeadRepo.IsProtectedBranch(pull.HeadBranch, ctx.User); err != nil {
1461+
if protected, err := pull.HeadRepo.IsProtectedBranch(pull.HeadBranch); err != nil {
14621462
log.Error("IsProtectedBranch: %v", err)
14631463
} else if !protected {
14641464
canDelete = true

routers/repo/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ func CleanUpPullRequest(ctx *context.Context) {
11901190
}
11911191

11921192
// Check if branch is not protected
1193-
if protected, err := pr.HeadRepo.IsProtectedBranch(pr.HeadBranch, ctx.User); err != nil || protected {
1193+
if protected, err := pr.HeadRepo.IsProtectedBranch(pr.HeadBranch); err != nil || protected {
11941194
if err != nil {
11951195
log.Error("HeadRepo.IsProtectedBranch: %v", err)
11961196
}

0 commit comments

Comments
 (0)