diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-10 03:57:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 20:57:58 +0100 |
commit | 99b2858e628d92bba252be72def409af77af735b (patch) | |
tree | 56159cf10b271307911e6f01626c0c3efba789ab /services/pull | |
parent | b6b1e716654fec3b16d245ef65cf42e57e1bb5b6 (diff) | |
download | gitea-99b2858e628d92bba252be72def409af77af735b.tar.gz gitea-99b2858e628d92bba252be72def409af77af735b.zip |
Move unit into models/unit/ (#17576)
* Move unit into models/unit/
* Rename unit.UnitType as unit.Type
Diffstat (limited to 'services/pull')
-rw-r--r-- | services/pull/check.go | 5 | ||||
-rw-r--r-- | services/pull/merge.go | 9 | ||||
-rw-r--r-- | services/pull/patch.go | 3 |
3 files changed, 10 insertions, 7 deletions
diff --git a/services/pull/check.go b/services/pull/check.go index c55b177e1c..1fb167ac21 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -13,6 +13,7 @@ import ( "strings" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" @@ -139,13 +140,13 @@ func manuallyMerged(pr *models.PullRequest) bool { return false } - if unit, err := pr.BaseRepo.GetUnit(models.UnitTypePullRequests); err == nil { + if unit, err := pr.BaseRepo.GetUnit(unit.TypePullRequests); err == nil { config := unit.PullRequestsConfig() if !config.AutodetectManualMerge { return false } } else { - log.Error("PullRequest[%d].BaseRepo.GetUnit(models.UnitTypePullRequests): %v", pr.ID, err) + log.Error("PullRequest[%d].BaseRepo.GetUnit(unit.TypePullRequests): %v", pr.ID, err) return false } diff --git a/services/pull/merge.go b/services/pull/merge.go index 4d4a64e984..f59931e1bf 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -16,6 +16,7 @@ import ( "time" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" @@ -38,9 +39,9 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor return fmt.Errorf("LoadBaseRepo: %v", err) } - prUnit, err := pr.BaseRepo.GetUnit(models.UnitTypePullRequests) + prUnit, err := pr.BaseRepo.GetUnit(unit.TypePullRequests) if err != nil { - log.Error("pr.BaseRepo.GetUnit(models.UnitTypePullRequests): %v", err) + log.Error("pr.BaseRepo.GetUnit(unit.TypePullRequests): %v", err) return err } prConfig := prUnit.PullRequestsConfig() @@ -565,7 +566,7 @@ func IsUserAllowedToMerge(pr *models.PullRequest, p models.Permission, user *mod return false, err } - if (p.CanWrite(models.UnitTypeCode) && pr.ProtectedBranch == nil) || (pr.ProtectedBranch != nil && pr.ProtectedBranch.IsUserMergeWhitelisted(user.ID, p)) { + if (p.CanWrite(unit.TypeCode) && pr.ProtectedBranch == nil) || (pr.ProtectedBranch != nil && pr.ProtectedBranch.IsUserMergeWhitelisted(user.ID, p)) { return true, nil } @@ -632,7 +633,7 @@ func CheckPRReadyToMerge(pr *models.PullRequest, skipProtectedFilesCheck bool) ( // MergedManually mark pr as merged manually func MergedManually(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repository, commitID string) (err error) { - prUnit, err := pr.BaseRepo.GetUnit(models.UnitTypePullRequests) + prUnit, err := pr.BaseRepo.GetUnit(unit.TypePullRequests) if err != nil { return } diff --git a/services/pull/patch.go b/services/pull/patch.go index 27d7991919..b971eb4bf3 100644 --- a/services/pull/patch.go +++ b/services/pull/patch.go @@ -14,6 +14,7 @@ import ( "strings" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/util" @@ -142,7 +143,7 @@ func checkConflicts(pr *models.PullRequest, gitRepo *git.Repository, tmpBasePath } // 4. Now get the pull request configuration to check if we need to ignore whitespace - prUnit, err := pr.BaseRepo.GetUnit(models.UnitTypePullRequests) + prUnit, err := pr.BaseRepo.GetUnit(unit.TypePullRequests) if err != nil { return false, err } |