aboutsummaryrefslogtreecommitdiffstats
path: root/services/pull/merge.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-06-12 23:51:54 +0800
committerGitHub <noreply@github.com>2022-06-12 23:51:54 +0800
commit110fc57cbcf293c19ed7017d8ea528b4bbbd7396 (patch)
treeb36eb2ee0e3f8417a35ad095e25880b778ded0ba /services/pull/merge.go
parenta9dc9b06e4a4106ec8315fe7b2922efa440ca199 (diff)
downloadgitea-110fc57cbcf293c19ed7017d8ea528b4bbbd7396.tar.gz
gitea-110fc57cbcf293c19ed7017d8ea528b4bbbd7396.zip
Move some code into models/git (#19879)
* Move access and repo permission to models/perm/access * fix test * Move some git related files into sub package models/git * Fix build * fix git test * move lfs to sub package * move more git related functions to models/git * Move functions sequence * Some improvements per @KN4CK3R and @delvh
Diffstat (limited to 'services/pull/merge.go')
-rw-r--r--services/pull/merge.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/services/pull/merge.go b/services/pull/merge.go
index 76798d73ed..eef1d17b64 100644
--- a/services/pull/merge.go
+++ b/services/pull/merge.go
@@ -19,6 +19,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ git_model "code.gitea.io/gitea/models/git"
access_model "code.gitea.io/gitea/models/perm/access"
pull_model "code.gitea.io/gitea/models/pull"
repo_model "code.gitea.io/gitea/models/repo"
@@ -756,7 +757,7 @@ func IsUserAllowedToMerge(ctx context.Context, pr *models.PullRequest, p access_
return false, err
}
- if (p.CanWrite(unit.TypeCode) && pr.ProtectedBranch == nil) || (pr.ProtectedBranch != nil && models.IsUserMergeWhitelisted(ctx, pr.ProtectedBranch, user.ID, p)) {
+ if (p.CanWrite(unit.TypeCode) && pr.ProtectedBranch == nil) || (pr.ProtectedBranch != nil && git_model.IsUserMergeWhitelisted(ctx, pr.ProtectedBranch, user.ID, p)) {
return true, nil
}
@@ -786,23 +787,23 @@ func CheckPullBranchProtections(ctx context.Context, pr *models.PullRequest, ski
}
}
- if !pr.ProtectedBranch.HasEnoughApprovals(ctx, pr) {
+ if !models.HasEnoughApprovals(ctx, pr.ProtectedBranch, pr) {
return models.ErrDisallowedToMerge{
Reason: "Does not have enough approvals",
}
}
- if pr.ProtectedBranch.MergeBlockedByRejectedReview(ctx, pr) {
+ if models.MergeBlockedByRejectedReview(ctx, pr.ProtectedBranch, pr) {
return models.ErrDisallowedToMerge{
Reason: "There are requested changes",
}
}
- if pr.ProtectedBranch.MergeBlockedByOfficialReviewRequests(ctx, pr) {
+ if models.MergeBlockedByOfficialReviewRequests(ctx, pr.ProtectedBranch, pr) {
return models.ErrDisallowedToMerge{
Reason: "There are official review requests",
}
}
- if pr.ProtectedBranch.MergeBlockedByOutdatedBranch(pr) {
+ if models.MergeBlockedByOutdatedBranch(pr.ProtectedBranch, pr) {
return models.ErrDisallowedToMerge{
Reason: "The head branch is behind the base branch",
}
@@ -812,7 +813,7 @@ func CheckPullBranchProtections(ctx context.Context, pr *models.PullRequest, ski
return nil
}
- if pr.ProtectedBranch.MergeBlockedByProtectedFiles(pr) {
+ if pr.ProtectedBranch.MergeBlockedByProtectedFiles(pr.ChangedProtectedFiles) {
return models.ErrDisallowedToMerge{
Reason: "Changed protected files",
}