diff --git a/routers/common/compare.go b/routers/common/compare.go index 98e2082b0c..a4a6d91e40 100644 --- a/routers/common/compare.go +++ b/routers/common/compare.go @@ -241,7 +241,10 @@ func ParseComparePathParams(ctx context.Context, pathParam string, baseRepo *rep var err error if pathParam == "" { - ci.HeadOriRef = baseRepo.DefaultBranch + ci.CompareRouter = &CompareRouter{ + HeadOriRef: baseRepo.DefaultBranch, + DotTimes: 3, + } } else { ci.CompareRouter, err = parseCompareRouter(pathParam) if err != nil { diff --git a/routers/common/compare_test.go b/routers/common/compare_test.go index 3469e424a3..de6093a295 100644 --- a/routers/common/compare_test.go +++ b/routers/common/compare_test.go @@ -21,6 +21,14 @@ func TestCompareRouters(t *testing.T) { router string compareRouter *CompareRouter }{ + { + router: "", + compareRouter: &CompareRouter{ + BaseOriRef: "", + HeadOriRef: "", + DotTimes: 3, + }, + }, { router: "main...develop", compareRouter: &CompareRouter{ @@ -175,6 +183,25 @@ func Test_ParseComparePathParams(t *testing.T) { router string compareInfo *CompareInfo }{ + { + repoName: "repo1", + router: "", + compareInfo: &CompareInfo{ + CompareRouter: &CompareRouter{ + BaseOriRef: "master", + BaseFullRef: git.RefNameFromBranch("master"), + HeadOriRef: "master", + HeadFullRef: git.RefNameFromBranch("master"), + HeadOwnerName: repo1.OwnerName, + HeadRepoName: repo1.Name, + DotTimes: 3, + }, + BaseRepo: repo1, + HeadUser: repo1.Owner, + HeadRepo: repo1, + HeadGitRepo: gitRepo1, + }, + }, { repoName: "repo1", router: "master...branch2",