Skip to content

Commit 287516b

Browse files
kdumontnujtran
andcommitted
Use beforeCommit instead of baseCommit
Co-authored-by: Jonathan Tran <[email protected]>
1 parent d9c6cb7 commit 287516b

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

routers/web/repo/compare.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const (
4343
)
4444

4545
// setCompareContext sets context data.
46-
func setCompareContext(ctx *context.Context, base, head *git.Commit, headOwner, headName string) {
47-
ctx.Data["BaseCommit"] = base
46+
func setCompareContext(ctx *context.Context, before, head *git.Commit, headOwner, headName string) {
47+
ctx.Data["BeforeCommit"] = before
4848
ctx.Data["HeadCommit"] = head
4949

5050
ctx.Data["GetBlobByPathForCommit"] = func(commit *git.Commit, path string) *git.Blob {
@@ -59,7 +59,7 @@ func setCompareContext(ctx *context.Context, base, head *git.Commit, headOwner,
5959
return blob
6060
}
6161

62-
setPathsCompareContext(ctx, base, head, headOwner, headName)
62+
setPathsCompareContext(ctx, before, head, headOwner, headName)
6363
setImageCompareContext(ctx)
6464
setCsvCompareContext(ctx)
6565
}
@@ -629,9 +629,8 @@ func PrepareCompareDiff(
629629
}
630630

631631
baseGitRepo := ctx.Repo.GitRepo
632-
baseCommitID := ci.CompareInfo.BaseCommitID
633632

634-
baseCommit, err := baseGitRepo.GetCommit(baseCommitID)
633+
beforeCommit, err := baseGitRepo.GetCommit(beforeCommitID)
635634
if err != nil {
636635
ctx.ServerError("GetCommit", err)
637636
return false
@@ -668,7 +667,7 @@ func PrepareCompareDiff(
668667
ctx.Data["Username"] = ci.HeadUser.Name
669668
ctx.Data["Reponame"] = ci.HeadRepo.Name
670669

671-
setCompareContext(ctx, baseCommit, headCommit, ci.HeadUser.Name, repo.Name)
670+
setCompareContext(ctx, beforeCommit, headCommit, ci.HeadUser.Name, repo.Name)
672671

673672
return false
674673
}

templates/repo/diff/box.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<div id="diff-file-boxes" class="sixteen wide column">
7272
{{range $i, $file := .Diff.Files}}
7373
{{/*notice: the index of Diff.Files should not be used for element ID, because the index will be restarted from 0 when doing load-more for PRs with a lot of files*/}}
74-
{{$blobBase := call $.GetBlobByPathForCommit $.BaseCommit $file.OldName}}
74+
{{$blobBase := call $.GetBlobByPathForCommit $.BeforeCommit $file.OldName}}
7575
{{$blobHead := call $.GetBlobByPathForCommit $.HeadCommit $file.Name}}
7676
{{$isImage := or (call $.IsBlobAnImage $blobBase) (call $.IsBlobAnImage $blobHead)}}
7777
{{$isCsv := (call $.IsCsvFile $file)}}

0 commit comments

Comments
 (0)