Skip to content

Commit

Permalink
Fix forking an empty repository (#6637) (#6653)
Browse files Browse the repository at this point in the history
Fixes #6633

Signed-off-by: Segev Finer <segev@codeocean.com>
  • Loading branch information
segevfiner authored and zeripath committed Apr 16, 2019
1 parent 5876e37 commit 5236d8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,7 @@ func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *R
Description: desc,
DefaultBranch: oldRepo.DefaultBranch,
IsPrivate: oldRepo.IsPrivate,
IsEmpty: oldRepo.IsEmpty,
IsFork: true,
ForkID: oldRepo.ID,
}
Expand Down
14 changes: 7 additions & 7 deletions modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,13 @@ func RepoAssignment() macaron.Handler {
ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.ID, repo.ID)
}

if repo.IsFork {
RetrieveBaseRepo(ctx, repo)
if ctx.Written() {
return
}
}

// repo is empty and display enable
if ctx.Repo.Repository.IsEmpty {
ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
Expand Down Expand Up @@ -423,13 +430,6 @@ func RepoAssignment() macaron.Handler {
ctx.Data["BranchName"] = ctx.Repo.BranchName
ctx.Data["CommitID"] = ctx.Repo.CommitID

if repo.IsFork {
RetrieveBaseRepo(ctx, repo)
if ctx.Written() {
return
}
}

// People who have push access or have forked repository can propose a new pull request.
if ctx.Repo.CanWrite(models.UnitTypeCode) || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) {
// Pull request is allowed if this is a fork repository
Expand Down

0 comments on commit 5236d8a

Please sign in to comment.