refactor(prdescribe): prefer remote base for diff calculation
Update the git diff command to first attempt using the remote origin/base branch, as it is more likely to be up-to-date for pull requests. Fall back to the local base branch if the remote diff fails or is empty.
This commit is contained in:
parent
e0e1100396
commit
029621b916
@ -26,10 +26,10 @@ func init() {
|
||||
func runPRDescribe(cmd *cobra.Command, _ []string) {
|
||||
base, _ := cmd.Flags().GetString("base")
|
||||
|
||||
// Prefer local base, fallback to origin/<base>.
|
||||
diff, err := gitDiff([]string{"diff", fmt.Sprintf("%s..HEAD", base), "--no-color"})
|
||||
// Prefer remote (more likely up-to-date for PRs), fallback to local.
|
||||
diff, err := gitDiff([]string{"diff", fmt.Sprintf("origin/%s..HEAD", base), "--no-color"})
|
||||
if err != nil || strings.TrimSpace(diff) == "" {
|
||||
diff, err = gitDiff([]string{"diff", fmt.Sprintf("origin/%s..HEAD", base), "--no-color"})
|
||||
diff, err = gitDiff([]string{"diff", fmt.Sprintf("%s..HEAD", base), "--no-color"})
|
||||
if err != nil {
|
||||
color.Red("Failed to get branch diff: %v", err)
|
||||
return
|
||||
|
||||
Loading…
Reference in New Issue
Block a user