pull/36105/head
Lunny Xiao 2025-12-10 11:07:46 +07:00
parent 229b20b6e9
commit 8a83a64ebf
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 40 additions and 28 deletions

@ -1099,8 +1099,13 @@ func parseCompareInfo(ctx *context.APIContext, compareParam string) (result *par
} }
} }
if compareReq.HeadRepoName == "" { if compareReq.HeadRepoName == "" {
if headUser.ID == baseRepo.OwnerID {
headRepo = baseRepo
} else {
// TODO: forked's fork
headRepo = repo_model.GetForkedRepo(ctx, headUser.ID, baseRepo.ID) headRepo = repo_model.GetForkedRepo(ctx, headUser.ID, baseRepo.ID)
if headRepo == nil && headUser.ID != baseRepo.OwnerID { if headRepo == nil {
// TODO: based's base?
err = baseRepo.GetBaseRepo(ctx) err = baseRepo.GetBaseRepo(ctx)
if err != nil { if err != nil {
ctx.APIErrorInternal(err) ctx.APIErrorInternal(err)
@ -1116,6 +1121,7 @@ func parseCompareInfo(ctx *context.APIContext, compareParam string) (result *par
// Assign headRepo so it can be used below. // Assign headRepo so it can be used below.
headRepo = baseRepo.BaseRepo headRepo = baseRepo.BaseRepo
} }
}
} else { } else {
if compareReq.HeadOwner == ctx.Repo.Owner.Name && compareReq.HeadRepoName == ctx.Repo.Repository.Name { if compareReq.HeadOwner == ctx.Repo.Owner.Name && compareReq.HeadRepoName == ctx.Repo.Repository.Name {
headRepo = ctx.Repo.Repository headRepo = ctx.Repo.Repository

@ -226,8 +226,13 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
} }
} }
if compareReq.HeadRepoName == "" { if compareReq.HeadRepoName == "" {
if ci.HeadUser.ID == baseRepo.OwnerID {
ci.HeadRepo = baseRepo
} else {
// TODO: forked's fork
ci.HeadRepo = repo_model.GetForkedRepo(ctx, ci.HeadUser.ID, baseRepo.ID) ci.HeadRepo = repo_model.GetForkedRepo(ctx, ci.HeadUser.ID, baseRepo.ID)
if ci.HeadRepo == nil && ci.HeadUser.ID != baseRepo.OwnerID { if ci.HeadRepo == nil {
// TODO: based's base?
err = baseRepo.GetBaseRepo(ctx) err = baseRepo.GetBaseRepo(ctx)
if err != nil { if err != nil {
ctx.ServerError("GetBaseRepo", err) ctx.ServerError("GetBaseRepo", err)
@ -243,6 +248,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
// Assign headRepo so it can be used below. // Assign headRepo so it can be used below.
ci.HeadRepo = baseRepo.BaseRepo ci.HeadRepo = baseRepo.BaseRepo
} }
}
} else { } else {
if compareReq.HeadOwner == ctx.Repo.Owner.Name && compareReq.HeadRepoName == ctx.Repo.Repository.Name { if compareReq.HeadOwner == ctx.Repo.Owner.Name && compareReq.HeadRepoName == ctx.Repo.Repository.Name {
ci.HeadRepo = ctx.Repo.Repository ci.HeadRepo = ctx.Repo.Repository