From 36c8ce7eeb9702a9c2f532b1424f124b3c04b32d Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 16 Dec 2021 20:49:57 +0800 Subject: [PATCH] Some improvements --- routers/web/repo/compare.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index fd5050792889..f6eb2ef8ebe7 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -221,19 +221,13 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo { } else { infos = strings.SplitN(infoPath, "...", 2) if len(infos) != 2 { - infos = []string{baseRepo.DefaultBranch, infoPath} - if strings.Contains(infoPath, "..") { - infos = strings.SplitN(infoPath, "..", 2) + if infos = strings.SplitN(infoPath, "..", 2); len(infos) == 2 { ci.DirectComparison = true ctx.Data["PageIsComparePull"] = false + } else { + infos = []string{baseRepo.DefaultBranch, infoPath} } } - - if len(infos) != 2 { - log.Trace("ParseCompareInfo[%d]: not enough compared branches information %s", baseRepo.ID, infos) - ctx.NotFound("CompareAndPullRequest", nil) - return nil - } } ctx.Data["BaseName"] = baseRepo.OwnerName