From 73920960f75bee4fd6dda932e3c3e58388775175 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 12:40:38 +0000 Subject: [PATCH 1/5] Initial plan From 1c01dcf6e1aaf84aa15f7f650ef2b5906dca8ce2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 12:55:44 +0000 Subject: [PATCH 2/5] fix: better error message when git commit fails during add-wizard When `git commit` fails during `gh add-wizard` (interactive mode), instead of rolling back workflow files and showing a cryptic error, the tool now: 1. Leaves the workflow files on disk and staged in git for manual recovery 2. Captures and displays git's actual error output in the error message 3. Shows clear instructions for the user to manually commit/push and create a pull request Fixes: failed to commit files: failed to commit changes: exit status 1 Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com> --- pkg/cli/add_workflow_pr.go | 25 +++++++++++++++++++++---- pkg/cli/git.go | 7 ++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/pkg/cli/add_workflow_pr.go b/pkg/cli/add_workflow_pr.go index 21c1ce19f9e..b5b04b2f3e5 100644 --- a/pkg/cli/add_workflow_pr.go +++ b/pkg/cli/add_workflow_pr.go @@ -1,6 +1,7 @@ package cli import ( + "errors" "fmt" "math/rand" "os" @@ -127,10 +128,26 @@ func addWorkflowsWithPR(workflows []*ResolvedWorkflow, opts AddOptions) (int, st } if err := commitChanges(commitMessage, opts.Verbose); err != nil { - if rollbackErr := tracker.RollbackAllFiles(opts.Verbose); rollbackErr != nil && opts.Verbose { - fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to rollback files: %v", rollbackErr))) - } - return 0, "", fmt.Errorf("failed to commit files: %w", err) + // Don't rollback - leave the workflow files on disk for manual recovery. + // Print clear instructions so the user can commit and push manually. + fmt.Fprintln(os.Stderr, "") + fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Failed to commit workflow files: %v", err))) + fmt.Fprintln(os.Stderr, "") + fmt.Fprintln(os.Stderr, "The workflow files have been written to disk and staged in git.") + fmt.Fprintln(os.Stderr, "Please commit the files manually, then either push them to the") + fmt.Fprintln(os.Stderr, "repository or create a pull request:") + fmt.Fprintln(os.Stderr, "") + fmt.Fprintln(os.Stderr, console.FormatCommandMessage(fmt.Sprintf(" git commit -m \"%s\"", commitMessage))) + fmt.Fprintln(os.Stderr, console.FormatCommandMessage(" git push")) + fmt.Fprintln(os.Stderr, "") + fmt.Fprintln(os.Stderr, "Or to create a pull request:") + fmt.Fprintln(os.Stderr, "") + fmt.Fprintln(os.Stderr, console.FormatCommandMessage(" git checkout -b "+branchName)) + fmt.Fprintln(os.Stderr, console.FormatCommandMessage(fmt.Sprintf(" git commit -m \"%s\"", commitMessage))) + fmt.Fprintln(os.Stderr, console.FormatCommandMessage(" git push -u origin "+branchName)) + fmt.Fprintln(os.Stderr, console.FormatCommandMessage(fmt.Sprintf(" gh pr create --title \"%s\"", prTitle))) + fmt.Fprintln(os.Stderr, "") + return 0, "", errors.New("failed to commit workflow files") } // Push branch diff --git a/pkg/cli/git.go b/pkg/cli/git.go index 166d82c58e3..9bfe06b775d 100644 --- a/pkg/cli/git.go +++ b/pkg/cli/git.go @@ -339,7 +339,12 @@ func commitChanges(message string, verbose bool) error { console.LogVerbose(verbose, "Committing changes with message: "+message) cmd := exec.Command("git", "commit", "-m", message) - if err := cmd.Run(); err != nil { + if output, err := cmd.CombinedOutput(); err != nil { + gitLog.Printf("Failed to commit: %v, output: %s", err, string(output)) + outputStr := strings.TrimSpace(string(output)) + if outputStr != "" { + return fmt.Errorf("failed to commit changes: %w\n%s", err, outputStr) + } return fmt.Errorf("failed to commit changes: %w", err) } From 0e05c85925c829890aaa017f1f15ba32b1fda9e7 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 26 Feb 2026 21:14:30 +0000 Subject: [PATCH 3/5] Update pkg/cli/add_workflow_pr.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pkg/cli/add_workflow_pr.go | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/pkg/cli/add_workflow_pr.go b/pkg/cli/add_workflow_pr.go index b5b04b2f3e5..7253a0cd200 100644 --- a/pkg/cli/add_workflow_pr.go +++ b/pkg/cli/add_workflow_pr.go @@ -129,25 +129,22 @@ func addWorkflowsWithPR(workflows []*ResolvedWorkflow, opts AddOptions) (int, st if err := commitChanges(commitMessage, opts.Verbose); err != nil { // Don't rollback - leave the workflow files on disk for manual recovery. - // Print clear instructions so the user can commit and push manually. - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Failed to commit workflow files: %v", err))) - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, "The workflow files have been written to disk and staged in git.") - fmt.Fprintln(os.Stderr, "Please commit the files manually, then either push them to the") - fmt.Fprintln(os.Stderr, "repository or create a pull request:") - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, console.FormatCommandMessage(fmt.Sprintf(" git commit -m \"%s\"", commitMessage))) - fmt.Fprintln(os.Stderr, console.FormatCommandMessage(" git push")) - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, "Or to create a pull request:") - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, console.FormatCommandMessage(" git checkout -b "+branchName)) - fmt.Fprintln(os.Stderr, console.FormatCommandMessage(fmt.Sprintf(" git commit -m \"%s\"", commitMessage))) - fmt.Fprintln(os.Stderr, console.FormatCommandMessage(" git push -u origin "+branchName)) - fmt.Fprintln(os.Stderr, console.FormatCommandMessage(fmt.Sprintf(" gh pr create --title \"%s\"", prTitle))) - fmt.Fprintln(os.Stderr, "") - return 0, "", errors.New("failed to commit workflow files") + // Return a richly formatted error with clear instructions so the user can + // commit and push manually. The top-level error handler will print this. + return 0, "", fmt.Errorf( + "failed to commit workflow files: %w\n\n"+ + "The workflow files have been written to disk and staged in git.\n"+ + "Please commit the files manually, then either push them to the\n"+ + "repository or create a pull request:\n\n"+ + " git commit -m %q\n"+ + " git push\n\n"+ + "Or to create a pull request:\n\n"+ + " git checkout -b %s\n"+ + " git commit -m %q\n"+ + " git push -u origin %s\n"+ + " gh pr create --title %q\n", + err, commitMessage, branchName, commitMessage, branchName, prTitle, + ) } // Push branch From 581d8f6e011e1e7c814d6b27f896f97166ff1b33 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Thu, 26 Feb 2026 21:15:26 +0000 Subject: [PATCH 4/5] Update pkg/cli/git.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pkg/cli/git.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/cli/git.go b/pkg/cli/git.go index 9bfe06b775d..8247c5ccf0c 100644 --- a/pkg/cli/git.go +++ b/pkg/cli/git.go @@ -342,10 +342,7 @@ func commitChanges(message string, verbose bool) error { if output, err := cmd.CombinedOutput(); err != nil { gitLog.Printf("Failed to commit: %v, output: %s", err, string(output)) outputStr := strings.TrimSpace(string(output)) - if outputStr != "" { - return fmt.Errorf("failed to commit changes: %w\n%s", err, outputStr) - } - return fmt.Errorf("failed to commit changes: %w", err) + return fmt.Errorf("failed to commit changes: %w\n%s", err, outputStr) } return nil From 55e236076b43679e75b16cf683abe300ba9e8bbd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 21:39:30 +0000 Subject: [PATCH 5/5] fix: remove unused errors import causing build failure Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com> --- pkg/cli/add_workflow_pr.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/cli/add_workflow_pr.go b/pkg/cli/add_workflow_pr.go index 7253a0cd200..995702a4c94 100644 --- a/pkg/cli/add_workflow_pr.go +++ b/pkg/cli/add_workflow_pr.go @@ -1,7 +1,6 @@ package cli import ( - "errors" "fmt" "math/rand" "os" @@ -142,7 +141,7 @@ func addWorkflowsWithPR(workflows []*ResolvedWorkflow, opts AddOptions) (int, st " git checkout -b %s\n"+ " git commit -m %q\n"+ " git push -u origin %s\n"+ - " gh pr create --title %q\n", + " gh pr create --title %q", err, commitMessage, branchName, commitMessage, branchName, prTitle, ) }