Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forking an empty repository #6637

Merged
merged 2 commits into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2436,6 +2436,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