-
Notifications
You must be signed in to change notification settings - Fork 30
🔧 Add --force flag to PR transfer command #4319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a --force flag to the PR transfer command that enables transferring PRs with conflicts by creating a PR with conflict markers and .rej files, providing more flexibility when handling complex patch applications that don't apply cleanly.
- Added
--force/-fflag to PR transfer command - Modified conflict handling to create PRs with conflict markers when
--forceis enabled - Enhanced commit messages to warn about included conflicts
- Updated help text with force flag usage examples
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/cli/pr_command.go | Added --force flag parameter throughout transfer flow, implemented conflict handling logic with --reject option, and enhanced commit messages to indicate presence of conflicts |
| pkg/cli/pr_command_test.go | Added test to verify --force flag exists on transfer subcommand |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if verbose { | ||
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Applying patch with --reject to create conflict markers...")) | ||
| } | ||
| rejectCmd := exec.Command("git", "apply", "--reject", patchFile) |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rejectCmd variable is declared twice in the same code path. It's first declared on line 376 (inside the verbose block) and then redeclared on line 393 (in the force mode block). While this works due to Go's scoping rules, it could lead to confusion.
Consider using a single declaration or using different variable names to make the code clearer.
| rejFilesCmd := exec.Command("sh", "-c", "find . -name '*.rej' -type f") | ||
| rejFilesOutput, _ := rejFilesCmd.Output() | ||
| hasConflicts := len(strings.TrimSpace(string(rejFilesOutput))) > 0 | ||
|
|
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using sh -c "find . -name '*.rej' -type f" to detect .rej files may have portability issues on Windows systems where sh might not be available. Additionally, running find from the current directory (.) could potentially search the entire repository including unrelated directories.
Consider using Go's filepath.Walk or filepath.Glob for better portability, or at least constraining the search to the git working tree with git ls-files '*.rej'.
| rejFilesCmd := exec.Command("sh", "-c", "find . -name '*.rej' -type f") | |
| rejFilesOutput, _ := rejFilesCmd.Output() | |
| hasConflicts := len(strings.TrimSpace(string(rejFilesOutput))) > 0 | |
| hasConflicts := false | |
| err := filepath.WalkDir(".", func(path string, d os.DirEntry, err error) error { | |
| if err != nil { | |
| return err | |
| } | |
| if !d.IsDir() && strings.HasSuffix(d.Name(), ".rej") { | |
| hasConflicts = true | |
| // Stop walking as soon as we find one | |
| return filepath.SkipDir | |
| } | |
| return nil | |
| }) | |
| if err != nil && verbose { | |
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Error searching for .rej files: %v", err))) | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Summary
--forceflag for the PR transfer commandChanges
transferPRandapplyPatchToRepofunctions to support--forceflagBehavior
--force: Fail on conflicts and provide an error message--force: