Skip to content

Commit 760cf41

Browse files
kdumontnujtran
andauthored
Use beforeCommit instead of baseCommit (#22949) (#22996)
Backport #22949 Fixes #22946 Probably related to #19530 Co-authored-by: Jonathan Tran <[email protected]>
1 parent 90982bf commit 760cf41

19 files changed

+109
-10
lines changed

models/fixtures/repo_unit.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,3 +544,16 @@
544544
repo_id: 51
545545
type: 2
546546
created_unix: 946684810
547+
548+
-
549+
id: 80
550+
repo_id: 31
551+
type: 1
552+
created_unix: 946684810
553+
554+
-
555+
id: 81
556+
repo_id: 31
557+
type: 3
558+
config: "{\"IgnoreWhitespaceConflicts\":false,\"AllowMerge\":true,\"AllowRebase\":true,\"AllowRebaseMerge\":true,\"AllowSquash\":true}"
559+
created_unix: 946684810

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)}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
"/home/tris/Projects/go/src/code.gitea.io/gitea/gitea" hook --config='/home/tris/Projects/go/src/code.gitea.io/gitea/custom/conf/app.ini' post-receive
2+
"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" post-receive
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
"/home/tris/Projects/go/src/code.gitea.io/gitea/gitea" hook --config='/home/tris/Projects/go/src/code.gitea.io/gitea/custom/conf/app.ini' pre-receive
2+
"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" pre-receive
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
"/home/tris/Projects/go/src/code.gitea.io/gitea/gitea" hook --config='/home/tris/Projects/go/src/code.gitea.io/gitea/custom/conf/app.ini' update $1 $2 $3
2+
"$GITEA_ROOT/gitea" hook --config="$GITEA_ROOT/$GITEA_CONF" update $1 $2 $3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
x��An�0 s�+���l� �[_A�TkIJC>���z[,f1��Z�!�K�̀��S��L5[,�D҉'�:a�Rнe���Dl� �:^C�g�lH�d���>iqr��m��s1���K���m=?U��3o������������k�ߝ{��@w�ʼ���E]

0 commit comments

Comments
 (0)