Skip to content

Commit 5236d8a

Browse files
segevfinerzeripath
authored andcommitted
Fix forking an empty repository (go-gitea#6637) (go-gitea#6653)
Fixes go-gitea#6633 Signed-off-by: Segev Finer <[email protected]>
1 parent 5876e37 commit 5236d8a

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

models/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,7 @@ func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *R
24322432
Description: desc,
24332433
DefaultBranch: oldRepo.DefaultBranch,
24342434
IsPrivate: oldRepo.IsPrivate,
2435+
IsEmpty: oldRepo.IsEmpty,
24352436
IsFork: true,
24362437
ForkID: oldRepo.ID,
24372438
}

modules/context/repo.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,13 @@ func RepoAssignment() macaron.Handler {
396396
ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.ID, repo.ID)
397397
}
398398

399+
if repo.IsFork {
400+
RetrieveBaseRepo(ctx, repo)
401+
if ctx.Written() {
402+
return
403+
}
404+
}
405+
399406
// repo is empty and display enable
400407
if ctx.Repo.Repository.IsEmpty {
401408
ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
@@ -423,13 +430,6 @@ func RepoAssignment() macaron.Handler {
423430
ctx.Data["BranchName"] = ctx.Repo.BranchName
424431
ctx.Data["CommitID"] = ctx.Repo.CommitID
425432

426-
if repo.IsFork {
427-
RetrieveBaseRepo(ctx, repo)
428-
if ctx.Written() {
429-
return
430-
}
431-
}
432-
433433
// People who have push access or have forked repository can propose a new pull request.
434434
if ctx.Repo.CanWrite(models.UnitTypeCode) || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) {
435435
// Pull request is allowed if this is a fork repository

0 commit comments

Comments
 (0)