mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
Merge two functions with the same content
This commit is contained in:
@@ -356,7 +356,11 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
|
||||
// "OwnForkRepo"
|
||||
var ownForkRepo *repo_model.Repository
|
||||
if ctx.Doer != nil && baseRepo.OwnerID != ctx.Doer.ID {
|
||||
repo := repo_model.GetForkedRepo(ctx, ctx.Doer.ID, baseRepo.ID)
|
||||
repo, err := repo_model.GetForkedRepo(ctx, ctx.Doer.ID, baseRepo.ID)
|
||||
if err != nil && !repo_model.IsErrRepoNotExist(err) {
|
||||
ctx.ServerError("GetForkedRepo", err)
|
||||
return nil
|
||||
}
|
||||
if repo != nil {
|
||||
ownForkRepo = repo
|
||||
ctx.Data["OwnForkRepo"] = ownForkRepo
|
||||
@@ -380,13 +384,21 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
|
||||
|
||||
// 5. If the headOwner has a fork of the baseRepo - use that
|
||||
if !has {
|
||||
ci.HeadRepo = repo_model.GetForkedRepo(ctx, ci.HeadUser.ID, baseRepo.ID)
|
||||
ci.HeadRepo, err = repo_model.GetForkedRepo(ctx, ci.HeadUser.ID, baseRepo.ID)
|
||||
if err != nil && !repo_model.IsErrRepoNotExist(err) {
|
||||
ctx.ServerError("GetForkedRepo", err)
|
||||
return nil
|
||||
}
|
||||
has = ci.HeadRepo != nil
|
||||
}
|
||||
|
||||
// 6. If the baseRepo is a fork and the headUser has a fork of that use that
|
||||
if !has && baseRepo.IsFork {
|
||||
ci.HeadRepo = repo_model.GetForkedRepo(ctx, ci.HeadUser.ID, baseRepo.ForkID)
|
||||
ci.HeadRepo, err = repo_model.GetForkedRepo(ctx, ci.HeadUser.ID, baseRepo.ForkID)
|
||||
if err != nil && !repo_model.IsErrRepoNotExist(err) {
|
||||
ctx.ServerError("GetForkedRepo", err)
|
||||
return nil
|
||||
}
|
||||
has = ci.HeadRepo != nil
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,11 @@ func ForkPost(ctx *context.Context) {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), tplFork, &form)
|
||||
return
|
||||
}
|
||||
repo := repo_model.GetForkedRepo(ctx, ctxUser.ID, traverseParentRepo.ID)
|
||||
repo, err := repo_model.GetForkedRepo(ctx, ctxUser.ID, traverseParentRepo.ID)
|
||||
if err != nil && !repo_model.IsErrRepoNotExist(err) {
|
||||
ctx.ServerError("GetForkedRepo", err)
|
||||
return
|
||||
}
|
||||
if repo != nil {
|
||||
ctx.Redirect(ctxUser.HomeLink() + "/" + url.PathEscape(repo.Name))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user