|
|
@ -174,13 +174,6 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !repo.AllowsPulls() { |
|
|
|
|
|
|
|
// We can stop there's no need to go any further
|
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, private.HookPostReceiveResult{ |
|
|
|
|
|
|
|
RepoWasEmpty: wasEmpty, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
baseRepo = repo |
|
|
|
baseRepo = repo |
|
|
|
|
|
|
|
|
|
|
|
if repo.IsFork { |
|
|
|
if repo.IsFork { |
|
|
@ -192,10 +185,20 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if repo.BaseRepo.AllowsPulls() { |
|
|
|
baseRepo = repo.BaseRepo |
|
|
|
baseRepo = repo.BaseRepo |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !baseRepo.AllowsPulls() { |
|
|
|
|
|
|
|
// We can stop there's no need to go any further
|
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, private.HookPostReceiveResult{ |
|
|
|
|
|
|
|
RepoWasEmpty: wasEmpty, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// If our branch is the default branch of an unforked repo - there's no PR to create or refer to
|
|
|
|
// If our branch is the default branch of an unforked repo - there's no PR to create or refer to
|
|
|
|
if !repo.IsFork && branch == baseRepo.DefaultBranch { |
|
|
|
if !repo.IsFork && branch == baseRepo.DefaultBranch { |
|
|
|
results = append(results, private.HookPostReceiveBranchResult{}) |
|
|
|
results = append(results, private.HookPostReceiveBranchResult{}) |
|
|
@ -218,14 +221,14 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) { |
|
|
|
branch = fmt.Sprintf("%s:%s", repo.OwnerName, branch) |
|
|
|
branch = fmt.Sprintf("%s:%s", repo.OwnerName, branch) |
|
|
|
} |
|
|
|
} |
|
|
|
results = append(results, private.HookPostReceiveBranchResult{ |
|
|
|
results = append(results, private.HookPostReceiveBranchResult{ |
|
|
|
Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(), |
|
|
|
Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(), |
|
|
|
Create: true, |
|
|
|
Create: true, |
|
|
|
Branch: branch, |
|
|
|
Branch: branch, |
|
|
|
URL: fmt.Sprintf("%s/compare/%s...%s", baseRepo.HTMLURL(), util.PathEscapeSegments(baseRepo.DefaultBranch), util.PathEscapeSegments(branch)), |
|
|
|
URL: fmt.Sprintf("%s/compare/%s...%s", baseRepo.HTMLURL(), util.PathEscapeSegments(baseRepo.DefaultBranch), util.PathEscapeSegments(branch)), |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
results = append(results, private.HookPostReceiveBranchResult{ |
|
|
|
results = append(results, private.HookPostReceiveBranchResult{ |
|
|
|
Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(), |
|
|
|
Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(), |
|
|
|
Create: false, |
|
|
|
Create: false, |
|
|
|
Branch: branch, |
|
|
|
Branch: branch, |
|
|
|
URL: fmt.Sprintf("%s/pulls/%d", baseRepo.HTMLURL(), pr.Index), |
|
|
|
URL: fmt.Sprintf("%s/pulls/%d", baseRepo.HTMLURL(), pr.Index), |
|
|
|