diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-03-31 04:50:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 04:50:59 +0800 |
commit | 72111e698ea95abef06bf915cf850b0e75867a1a (patch) | |
tree | befeb2419e63be54e48d304a2e611d1fdabe6194 /internal/route/repo | |
parent | dce70fe6d17e1ffa9f276b9df8768924f025216b (diff) |
template: better diff handling of rename and deleted files (#6048)
* dep: bump github.com/gogs/git-module from 1.0.2 to 1.1.0
* template: better diff handling or rename and deleted files
Diffstat (limited to 'internal/route/repo')
-rw-r--r-- | internal/route/repo/commit.go | 8 | ||||
-rw-r--r-- | internal/route/repo/pull.go | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/internal/route/repo/commit.go b/internal/route/repo/commit.go index e8ff3380..00be5b1a 100644 --- a/internal/route/repo/commit.go +++ b/internal/route/repo/commit.go @@ -152,16 +152,18 @@ func Diff(c *context.Context) { c.Data["Username"] = userName c.Data["Reponame"] = repoName c.Data["IsImageFile"] = commit.IsImageFile + c.Data["IsImageFileByIndex"] = commit.IsImageFileByIndex c.Data["Commit"] = commit c.Data["Author"] = db.ValidateCommitWithEmail(commit) c.Data["Diff"] = diff c.Data["Parents"] = parents c.Data["DiffNotAvailable"] = diff.NumFiles() == 0 c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", commitID) + c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "raw", commitID) if commit.ParentsCount() > 0 { c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", parents[0]) + c.Data["BeforeRawPath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "raw", parents[0]) } - c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "raw", commitID) c.Success(DIFF) } @@ -213,12 +215,14 @@ func CompareDiff(c *context.Context) { c.Data["Username"] = userName c.Data["Reponame"] = repoName c.Data["IsImageFile"] = commit.IsImageFile + c.Data["IsImageFileByIndex"] = commit.IsImageFileByIndex c.Data["Title"] = "Comparing " + tool.ShortSHA1(beforeCommitID) + "..." + tool.ShortSHA1(afterCommitID) + " · " + userName + "/" + repoName c.Data["Commit"] = commit c.Data["Diff"] = diff c.Data["DiffNotAvailable"] = diff.NumFiles() == 0 c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", afterCommitID) - c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", beforeCommitID) c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "raw", afterCommitID) + c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "src", beforeCommitID) + c.Data["BeforeRawPath"] = conf.Server.Subpath + "/" + path.Join(userName, repoName, "raw", beforeCommitID) c.Success(DIFF) } diff --git a/internal/route/repo/pull.go b/internal/route/repo/pull.go index 14e9a5c3..7e064f40 100644 --- a/internal/route/repo/pull.go +++ b/internal/route/repo/pull.go @@ -378,6 +378,7 @@ func ViewPullFiles(c *context.Context) { c.Data["IsSplitStyle"] = c.Query("style") == "split" c.Data["IsImageFile"] = commit.IsImageFile + c.Data["IsImageFileByIndex"] = commit.IsImageFileByIndex // It is possible head repo has been deleted for merged pull requests if pull.HeadRepo != nil { @@ -386,8 +387,9 @@ func ViewPullFiles(c *context.Context) { headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name) c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", endCommitID) - c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", startCommitID) c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "raw", endCommitID) + c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", startCommitID) + c.Data["BeforeRawPath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "raw", startCommitID) } c.Data["RequireHighlightJS"] = true @@ -595,11 +597,13 @@ func PrepareCompareDiff( c.Data["Username"] = headUser.Name c.Data["Reponame"] = headRepo.Name c.Data["IsImageFile"] = headCommit.IsImageFile + c.Data["IsImageFileByIndex"] = headCommit.IsImageFileByIndex headTarget := path.Join(headUser.Name, repo.Name) c.Data["SourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", headCommitID) - c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", meta.MergeBase) c.Data["RawPath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "raw", headCommitID) + c.Data["BeforeSourcePath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "src", meta.MergeBase) + c.Data["BeforeRawPath"] = conf.Server.Subpath + "/" + path.Join(headTarget, "raw", meta.MergeBase) return false } |