Skip to content

Commit 0f28aa1

Browse files
committed
rename returned variables of IsUserAllowedToUpdate
1 parent 309b147 commit 0f28aa1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

services/pull/update.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func Update(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.
102102

103103
// IsUserAllowedToUpdate check if user is allowed to update PR with given permissions and branch protections
104104
// update PR means send new commits to PR head branch from base branch
105-
func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest, user *user_model.User) (mergeAllowed, rebaseAllowed bool, err error) {
105+
func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest, user *user_model.User) (updateByMergeAllowed, updateByRebaseAllowed bool, err error) {
106106
if pull.Flow == issues_model.PullRequestFlowAGit {
107107
return false, false, nil
108108
}
@@ -129,7 +129,7 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest,
129129
log.Error("pr.BaseRepo.GetUnit(unit.TypePullRequests): %v", err)
130130
return false, false, err
131131
}
132-
rebaseAllowed = prUnit.PullRequestsConfig().AllowRebaseUpdate
132+
updateByRebaseAllowed = prUnit.PullRequestsConfig().AllowRebaseUpdate
133133

134134
pb, err := git_model.GetFirstMatchProtectedBranchRule(ctx, pull.HeadRepoID, pull.HeadBranch)
135135
if err != nil {
@@ -138,10 +138,10 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest,
138138
// If branch protected, disable rebase unless user is whitelisted to force push (which extends regular push)
139139
if pb != nil {
140140
pb.Repo = pull.HeadRepo
141-
rebaseAllowed = rebaseAllowed && pb.CanUserForcePush(ctx, user)
142-
mergeAllowed = git_model.IsUserMergeWhitelisted(ctx, pb, user.ID, headRepoPerm)
141+
updateByRebaseAllowed = updateByRebaseAllowed && pb.CanUserForcePush(ctx, user)
142+
updateByMergeAllowed = git_model.IsUserMergeWhitelisted(ctx, pb, user.ID, headRepoPerm)
143143
} else {
144-
mergeAllowed = headRepoPerm.CanWrite(unit.TypeCode)
144+
updateByMergeAllowed = headRepoPerm.CanWrite(unit.TypeCode)
145145
}
146146

147147
baseRepoPerm, err := access_model.GetUserRepoPermission(ctx, pull.BaseRepo, user)
@@ -150,12 +150,12 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest,
150150
}
151151

152152
if pull.AllowMaintainerEdit {
153-
mergeAllowed = mergeAllowed || baseRepoPerm.CanWrite(unit.TypeCode)
153+
updateByMergeAllowed = updateByMergeAllowed || baseRepoPerm.CanWrite(unit.TypeCode)
154154
}
155155
// if merge is not allowed, rebase is also not allowed
156-
rebaseAllowed = rebaseAllowed && mergeAllowed
156+
updateByRebaseAllowed = updateByRebaseAllowed && updateByMergeAllowed
157157

158-
return mergeAllowed, rebaseAllowed, nil
158+
return updateByMergeAllowed, updateByRebaseAllowed, nil
159159
}
160160

161161
func syncCommitDivergence(ctx context.Context, pr *issues_model.PullRequest) error {

0 commit comments

Comments
 (0)