Skip to content
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
21 changes: 17 additions & 4 deletions pkg/cli/add_workflow_pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,23 @@ 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.
// 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",
err, commitMessage, branchName, commitMessage, branchName, prTitle,
)
}

// Push branch
Expand Down
6 changes: 4 additions & 2 deletions pkg/cli/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,10 @@ 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 {
return fmt.Errorf("failed to commit changes: %w", err)
if output, err := cmd.CombinedOutput(); err != nil {
gitLog.Printf("Failed to commit: %v, output: %s", err, string(output))
outputStr := strings.TrimSpace(string(output))
return fmt.Errorf("failed to commit changes: %w\n%s", err, outputStr)
}

return nil
Expand Down
Loading