diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-09-06 10:20:09 +0800 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-09-05 22:20:09 -0400 |
commit | c03d75fbd51174d0e7ffdbaf9e9e253438d06cf7 (patch) | |
tree | a54e9fdfb6ff96baf7010d7fd5049a05a16644e2 /routers/repo | |
parent | b660a732ae283d863636ead9cc1a365ce1c0edc1 (diff) | |
download | gitea-c03d75fbd51174d0e7ffdbaf9e9e253438d06cf7.tar.gz gitea-c03d75fbd51174d0e7ffdbaf9e9e253438d06cf7.zip |
Move git diff codes from models to services/gitdiff (#7889)
* move git diff codes from models to services/gitdiff
* fix template
* fix test
* fix template
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/commit.go | 7 | ||||
-rw-r--r-- | routers/repo/compare.go | 3 | ||||
-rw-r--r-- | routers/repo/pull.go | 3 | ||||
-rw-r--r-- | routers/repo/pull_review.go | 3 |
4 files changed, 10 insertions, 6 deletions
diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 79fa024dc9..c3181cbe46 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/services/gitdiff" ) const ( @@ -217,7 +218,7 @@ func Diff(ctx *context.Context) { ctx.Data["CommitStatus"] = models.CalcCommitStatus(statuses) - diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), + diff, err := gitdiff.GetDiffCommit(models.RepoPath(userName, repoName), commitID, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles) if err != nil { @@ -269,10 +270,10 @@ func Diff(ctx *context.Context) { // RawDiff dumps diff results of repository in given commit ID to io.Writer func RawDiff(ctx *context.Context) { - if err := models.GetRawDiff( + if err := gitdiff.GetRawDiff( models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name), ctx.Params(":sha"), - models.RawDiffType(ctx.Params(":ext")), + gitdiff.RawDiffType(ctx.Params(":ext")), ctx.Resp, ); err != nil { ctx.ServerError("GetRawDiff", err) diff --git a/routers/repo/compare.go b/routers/repo/compare.go index 193255ca6c..4f9a918a7c 100644 --- a/routers/repo/compare.go +++ b/routers/repo/compare.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/services/gitdiff" ) const ( @@ -230,7 +231,7 @@ func PrepareCompareDiff( return true } - diff, err := models.GetDiffRange(models.RepoPath(headUser.Name, headRepo.Name), + diff, err := gitdiff.GetDiffRange(models.RepoPath(headUser.Name, headRepo.Name), compareInfo.MergeBase, headCommitID, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles) if err != nil { diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 22ccc7769c..14d2f50821 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -24,6 +24,7 @@ import ( "code.gitea.io/gitea/modules/pull" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" + "code.gitea.io/gitea/services/gitdiff" "github.com/unknwon/com" ) @@ -517,7 +518,7 @@ func ViewPullFiles(ctx *context.Context) { ctx.Data["Reponame"] = pull.HeadRepo.Name } - diff, err := models.GetDiffRangeWithWhitespaceBehavior(diffRepoPath, + diff, err := gitdiff.GetDiffRangeWithWhitespaceBehavior(diffRepoPath, startCommitID, endCommitID, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, whitespaceFlags[ctx.Data["WhitespaceBehavior"].(string)]) diff --git a/routers/repo/pull_review.go b/routers/repo/pull_review.go index cf93783042..d4e3a3326a 100644 --- a/routers/repo/pull_review.go +++ b/routers/repo/pull_review.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification" pull_service "code.gitea.io/gitea/modules/pull" + comment_service "code.gitea.io/gitea/services/comments" ) // CreateCodeComment will create a code comment including an pending review if required @@ -69,7 +70,7 @@ func CreateCodeComment(ctx *context.Context, form auth.CodeCommentForm) { review.ID = form.Reply } //FIXME check if line, commit and treepath exist - comment, err := models.CreateCodeComment( + comment, err := comment_service.CreateCodeComment( ctx.User, issue.Repo, issue, |