aboutsummaryrefslogtreecommitdiffstats
path: root/services/pull/pull.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/pull.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/pull.go')
-rw-r--r--services/pull/pull.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/services/pull/pull.go b/services/pull/pull.go
index efac3f019e..736520fda2 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -16,6 +16,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
@@ -735,13 +736,13 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *models.PullRequest) s
}
// GetIssuesLastCommitStatus returns a map of issue ID to the most recent commit's latest status
-func GetIssuesLastCommitStatus(ctx context.Context, issues models.IssueList) (map[int64]*models.CommitStatus, error) {
+func GetIssuesLastCommitStatus(ctx context.Context, issues models.IssueList) (map[int64]*git_model.CommitStatus, error) {
_, lastStatus, err := GetIssuesAllCommitStatus(ctx, issues)
return lastStatus, err
}
// GetIssuesAllCommitStatus returns a map of issue ID to a list of all statuses for the most recent commit as well as a map of issue ID to only the commit's latest status
-func GetIssuesAllCommitStatus(ctx context.Context, issues models.IssueList) (map[int64][]*models.CommitStatus, map[int64]*models.CommitStatus, error) {
+func GetIssuesAllCommitStatus(ctx context.Context, issues models.IssueList) (map[int64][]*git_model.CommitStatus, map[int64]*git_model.CommitStatus, error) {
if err := issues.LoadPullRequests(); err != nil {
return nil, nil, err
}
@@ -751,8 +752,8 @@ func GetIssuesAllCommitStatus(ctx context.Context, issues models.IssueList) (map
var (
gitRepos = make(map[int64]*git.Repository)
- res = make(map[int64][]*models.CommitStatus)
- lastRes = make(map[int64]*models.CommitStatus)
+ res = make(map[int64][]*git_model.CommitStatus)
+ lastRes = make(map[int64]*git_model.CommitStatus)
err error
)
defer func() {
@@ -787,14 +788,14 @@ func GetIssuesAllCommitStatus(ctx context.Context, issues models.IssueList) (map
}
// getAllCommitStatus get pr's commit statuses.
-func getAllCommitStatus(gitRepo *git.Repository, pr *models.PullRequest) (statuses []*models.CommitStatus, lastStatus *models.CommitStatus, err error) {
+func getAllCommitStatus(gitRepo *git.Repository, pr *models.PullRequest) (statuses []*git_model.CommitStatus, lastStatus *git_model.CommitStatus, err error) {
sha, shaErr := gitRepo.GetRefCommitID(pr.GetGitRefName())
if shaErr != nil {
return nil, nil, shaErr
}
- statuses, _, err = models.GetLatestCommitStatus(db.DefaultContext, pr.BaseRepo.ID, sha, db.ListOptions{})
- lastStatus = models.CalcCommitStatus(statuses)
+ statuses, _, err = git_model.GetLatestCommitStatus(db.DefaultContext, pr.BaseRepo.ID, sha, db.ListOptions{})
+ lastStatus = git_model.CalcCommitStatus(statuses)
return statuses, lastStatus, err
}