summaryrefslogtreecommitdiffstats
path: root/routers/repo/commit.go
diff options
context:
space:
mode:
authorMario Lubenka <mario.lubenka@googlemail.com>2019-10-04 21:58:54 +0200
committertechknowlogick <techknowlogick@gitea.io>2019-10-04 15:58:54 -0400
commitf92a0b68fed81128fa278e82aa0e3d49d74ffdf6 (patch)
tree41a6a7cd2a8a6153046851b5ab3a9c5aacb0cdfd /routers/repo/commit.go
parentde8a0a3938e811ffaa6800a771d7f09fd6428608 (diff)
downloadgitea-f92a0b68fed81128fa278e82aa0e3d49d74ffdf6.tar.gz
gitea-f92a0b68fed81128fa278e82aa0e3d49d74ffdf6.zip
Bugfix for image compare and minor improvements to image compare (#8289)
* Resolve error when comparing images Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Check blob existence instead of git-ls when checking if file exists Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show file metadata also when a file was newly added Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Fixes error in commit view Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Excludes assigning path and image infos for compare routers to service package Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Removes nil default and fixes import order Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adds missing comments Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Moves methods for assigning compare data to context into repo router package Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show image compare for deleted images as well. Simplify check if image should be displayed Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Diffstat (limited to 'routers/repo/commit.go')
-rw-r--r--routers/repo/commit.go24
1 files changed, 6 insertions, 18 deletions
diff --git a/routers/repo/commit.go b/routers/repo/commit.go
index 919ebabf42..3cedf70319 100644
--- a/routers/repo/commit.go
+++ b/routers/repo/commit.go
@@ -239,24 +239,18 @@ func Diff(ctx *context.Context) {
ctx.Data["CommitID"] = commitID
ctx.Data["Username"] = userName
ctx.Data["Reponame"] = repoName
- ctx.Data["IsImageFile"] = commit.IsImageFile
- ctx.Data["ImageInfo"] = func(name string) *git.ImageMetaData {
- result, err := commit.ImageInfo(name)
- if err != nil {
- log.Error("ImageInfo failed: %v", err)
- return nil
- }
- return result
- }
- ctx.Data["ImageInfoBase"] = ctx.Data["ImageInfo"]
+
+ var parentCommit *git.Commit
if commit.ParentCount() > 0 {
- parentCommit, err := ctx.Repo.GitRepo.GetCommit(parents[0])
+ parentCommit, err = ctx.Repo.GitRepo.GetCommit(parents[0])
if err != nil {
ctx.NotFound("GetParentCommit", err)
return
}
- ctx.Data["ImageInfo"] = parentCommit.ImageInfo
}
+ setImageCompareContext(ctx, parentCommit, commit)
+ headTarget := path.Join(userName, repoName)
+ setPathsCompareContext(ctx, parentCommit, commit, headTarget)
ctx.Data["Title"] = commit.Summary() + " ยท " + base.ShortSha(commitID)
ctx.Data["Commit"] = commit
ctx.Data["Verification"] = models.ParseCommitWithSignature(commit)
@@ -264,8 +258,6 @@ func Diff(ctx *context.Context) {
ctx.Data["Diff"] = diff
ctx.Data["Parents"] = parents
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
- ctx.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", "commit", commitID)
- ctx.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "raw", "commit", commitID)
note := &git.Note{}
err = git.GetNote(ctx.Repo.GitRepo, commitID, note)
@@ -275,10 +267,6 @@ func Diff(ctx *context.Context) {
ctx.Data["NoteAuthor"] = models.ValidateCommitWithEmail(note.Commit)
}
- if commit.ParentCount() > 0 {
- ctx.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", "commit", parents[0])
- ctx.Data["BeforeRawPath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "raw", "commit", parents[0])
- }
ctx.Data["BranchName"], err = commit.GetBranchName()
if err != nil {
ctx.ServerError("commit.GetBranchName", err)