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:
parent
3dd931086e
commit
62e21e823f
@ -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 {
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user