aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/commit.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-10-15 17:05:33 +0100
committerGitHub <noreply@github.com>2021-10-15 17:05:33 +0100
commita889d0cc8c70431d43a9e46a6cf859f7b490aeb3 (patch)
treeaa1f734e2e6442d8f4c41233ac542b40e665a29d /routers/web/repo/commit.go
parentbdfd751af88c5bdb70dbdfb4f7f607f6fbf77896 (diff)
downloadgitea-a889d0cc8c70431d43a9e46a6cf859f7b490aeb3.tar.gz
gitea-a889d0cc8c70431d43a9e46a6cf859f7b490aeb3.zip
Add buttons to allow loading of incomplete diffs (#16829)
This PR adds two buttons to the stats and the end of the diffs list to load the (some of) the remaining incomplete diff sections. Contains #16775 Signed-off-by: Andrew Thornton <art27@cantab.net> ## Screenshots ### Show more button at the end of the diff ![Screenshot from 2021-09-04 11-12-37](https://user-images.githubusercontent.com/1824502/132091009-b1f6113e-2c04-4be5-8a04-b8ecea56887b.png) ### Show more button at the end of the diff stats box ![Screenshot from 2021-09-04 11-14-54](https://user-images.githubusercontent.com/1824502/132091063-86da5a6d-6628-4b82-bea9-3655cd9f40f6.png)
Diffstat (limited to 'routers/web/repo/commit.go')
-rw-r--r--routers/web/repo/commit.go27
1 files changed, 17 insertions, 10 deletions
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go
index c5f3f70c1c..4c0f94f15d 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -264,6 +264,8 @@ func Diff(ctx *context.Context) {
err error
)
+ fileOnly := ctx.FormBool("file-only")
+
if ctx.Data["PageIsWiki"] != nil {
gitRepo, err = git.OpenRepository(ctx.Repo.Repository.WikiPath())
if err != nil {
@@ -288,16 +290,8 @@ func Diff(ctx *context.Context) {
commitID = commit.ID.String()
}
- statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, commitID, db.ListOptions{})
- if err != nil {
- log.Error("GetLatestCommitStatus: %v", err)
- }
-
- ctx.Data["CommitStatus"] = models.CalcCommitStatus(statuses)
- ctx.Data["CommitStatuses"] = statuses
-
diff, err := gitdiff.GetDiffCommitWithWhitespaceBehavior(gitRepo,
- commitID, setting.Git.MaxGitDiffLines,
+ commitID, ctx.FormString("skip-to"), setting.Git.MaxGitDiffLines,
setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles,
gitdiff.GetWhitespaceFlag(ctx.Data["WhitespaceBehavior"].(string)),
false)
@@ -333,10 +327,23 @@ func Diff(ctx *context.Context) {
setCompareContext(ctx, parentCommit, commit, headTarget)
ctx.Data["Title"] = commit.Summary() + " ยท " + base.ShortSha(commitID)
ctx.Data["Commit"] = commit
+ ctx.Data["Diff"] = diff
+ if fileOnly {
+ ctx.HTML(http.StatusOK, tplDiffBox)
+ return
+ }
+
+ statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, commitID, db.ListOptions{})
+ if err != nil {
+ log.Error("GetLatestCommitStatus: %v", err)
+ }
+
+ ctx.Data["CommitStatus"] = models.CalcCommitStatus(statuses)
+ ctx.Data["CommitStatuses"] = statuses
+
verification := models.ParseCommitWithSignature(commit)
ctx.Data["Verification"] = verification
ctx.Data["Author"] = models.ValidateCommitWithEmail(commit)
- ctx.Data["Diff"] = diff
ctx.Data["Parents"] = parents
ctx.Data["DiffNotAvailable"] = diff.NumFiles == 0