]> source.dussan.org Git - gitea.git/commitdiff
Fix 2-dot direct compare to use the right base commit (#24133)
authorJonathan Tran <jonnytran@gmail.com>
Sun, 16 Apr 2023 07:27:23 +0000 (03:27 -0400)
committerGitHub <noreply@github.com>
Sun, 16 Apr 2023 07:27:23 +0000 (10:27 +0300)
For 2-dot direct compare, we should use the base commit in the title and
templates, as is used elsewhere, not the common ancestor which is used
for 3-dot compare. I believe that this change should have been included
in #22949.

routers/web/repo/compare.go

index c49eb762d8a66e8ef42e40fb1fbb511806e2862a..92abe0ce259176f37ee45a1a69d2522087aed8f4 100644 (file)
@@ -551,7 +551,11 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
                ctx.ServerError("GetCompareInfo", err)
                return nil
        }
-       ctx.Data["BeforeCommitID"] = ci.CompareInfo.MergeBase
+       if ci.DirectComparison {
+               ctx.Data["BeforeCommitID"] = ci.CompareInfo.BaseCommitID
+       } else {
+               ctx.Data["BeforeCommitID"] = ci.CompareInfo.MergeBase
+       }
 
        return ci
 }