0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-01-20 10:54:32 +01:00

Fix empty compare

This commit is contained in:
Lunny Xiao 2025-01-09 19:45:57 -08:00
parent 3dd931086e
commit 62e21e823f
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 31 additions and 1 deletions

View File

@ -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 {

View File

@ -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",