Fix forking an empty repository (#6637)

Fixes #6633

Signed-off-by: Segev Finer <segev@codeocean.com>
This commit is contained in:
Segev Finer 2019-04-15 23:48:35 +03:00 committed by techknowlogick
parent 3fb038c53a
commit ecfa5f1594
2 changed files with 8 additions and 7 deletions

View file

@ -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
@ -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