···
566
-
us, err := NewUnsignedClient(f.Knot, s.config.Dev)
568
-
log.Printf("failed to create unsigned client to %s: %v", f.Knot, err)
569
-
s.pages.Notice(w, "pull", "Failed to create a pull request. Try again later.")
573
-
caps, err := us.Capabilities()
575
-
log.Println("error fetching knot caps", f.Knot, err)
576
-
s.pages.Notice(w, "pull", "Failed to create a pull request. Try again later.")
// Determine PR type based on input parameters
isPushAllowed := f.RepoInfo(s, user).Roles.IsPushAllowed()
isBranchBased := isPushAllowed && sourceBranch != "" && fromFork == ""
isForkBased := fromFork != "" && sourceBranch != ""
isPatchBased := patch != "" && !isBranchBased && !isForkBased
572
+
if isPatchBased && !patchutil.IsFormatPatch(patch) {
574
+
s.pages.Notice(w, "pull", "Title is required for git-diff patches.")
// Validate we have at least one valid PR creation method
if !isBranchBased && !isPatchBased && !isForkBased {
s.pages.Notice(w, "pull", "Neither source branch nor patch supplied.")
···
591
+
us, err := NewUnsignedClient(f.Knot, s.config.Dev)
593
+
log.Printf("failed to create unsigned client to %s: %v", f.Knot, err)
594
+
s.pages.Notice(w, "pull", "Failed to create a pull request. Try again later.")
598
+
caps, err := us.Capabilities()
600
+
log.Println("error fetching knot caps", f.Knot, err)
601
+
s.pages.Notice(w, "pull", "Failed to create a pull request. Try again later.")
// Handle the PR creation based on the type
if !caps.PullRequests.BranchSubmissions {
···
771
+
// We've already checked earlier if it's diff-based and title is empty,
772
+
// so if it's still empty now, it's intentionally skipped owing to format-patch.
774
+
formatPatches, err := patchutil.ExtractPatches(patch)
776
+
s.pages.Notice(w, "pull", fmt.Sprintf("Failed to extract patches: %v", err))
779
+
if len(formatPatches) == 0 {
780
+
s.pages.Notice(w, "pull", "No patches found in the supplied format-patch.")
784
+
title = formatPatches[0].Title
785
+
body = formatPatches[0].Body
initialSubmission := db.PullSubmission{
···
if err = validateResubmittedPatch(pull, patch); err != nil {
s.pages.Notice(w, "resubmit-error", err.Error())
if sourceRev == pull.Submissions[pull.LastRoundNumber()].SourceRev {
···
return fmt.Errorf("Patch is identical to previous submission.")
1376
-
if patchutil.IsPatchValid(patch) {
1401
+
if !patchutil.IsPatchValid(patch) {
return fmt.Errorf("Invalid patch format. Please provide a valid diff.")