fix(sdlc): use remote ref for merge when local branch doesn't exist
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
After resetToMain in the executor, only remote refs exist for feature branches. The merge command now checks if the local branch exists and falls back to origin/<branch> when it doesn't. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2a2f2fa370
commit
8b5842682d
@ -113,12 +113,21 @@ var mergeCmd = &cobra.Command{
|
||||
_ = resetCmd.Run()
|
||||
}
|
||||
|
||||
// Determine merge ref: prefer local branch, fall back to origin/<branch>
|
||||
// when running in worker pods where resetToMain leaves only remote refs.
|
||||
mergeRef := f.Branch
|
||||
checkBranch := exec.Command("git", "rev-parse", "--verify", f.Branch)
|
||||
checkBranch.Dir = root
|
||||
if err := checkBranch.Run(); err != nil {
|
||||
mergeRef = "origin/" + f.Branch
|
||||
}
|
||||
|
||||
// Merge
|
||||
mergeArgs := []string{"merge"}
|
||||
if strategy == "squash" {
|
||||
mergeArgs = append(mergeArgs, "--squash")
|
||||
}
|
||||
mergeArgs = append(mergeArgs, f.Branch)
|
||||
mergeArgs = append(mergeArgs, mergeRef)
|
||||
|
||||
gitMerge := exec.Command("git", mergeArgs...)
|
||||
gitMerge.Dir = root
|
||||
|
||||
Loading…
Reference in New Issue
Block a user