fix(rig): dock/undock require main branch to prevent silent failures
Docking on non-main branches silently fails because rig identity beads live on main. The dock appeared to work but was lost on checkout to main. Now dock/undock check current branch and error with helpful message: "cannot dock: must be on main branch (currently on X)" Fixes hq-kc7 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -66,6 +66,18 @@ func init() {
|
||||
func runRigDock(cmd *cobra.Command, args []string) error {
|
||||
rigName := args[0]
|
||||
|
||||
// Check we're on main branch - docking on other branches won't persist
|
||||
branchCmd := exec.Command("git", "branch", "--show-current")
|
||||
branchOutput, err := branchCmd.Output()
|
||||
if err == nil {
|
||||
currentBranch := string(branchOutput)
|
||||
currentBranch = currentBranch[:len(currentBranch)-1] // trim newline
|
||||
if currentBranch != "main" && currentBranch != "master" {
|
||||
return fmt.Errorf("cannot dock: must be on main branch (currently on %s)\n"+
|
||||
"Docking on other branches won't persist. Run: git checkout main", currentBranch)
|
||||
}
|
||||
}
|
||||
|
||||
// Get rig
|
||||
_, r, err := getRig(rigName)
|
||||
if err != nil {
|
||||
@@ -166,6 +178,18 @@ func runRigDock(cmd *cobra.Command, args []string) error {
|
||||
func runRigUndock(cmd *cobra.Command, args []string) error {
|
||||
rigName := args[0]
|
||||
|
||||
// Check we're on main branch - undocking on other branches won't persist
|
||||
branchCmd := exec.Command("git", "branch", "--show-current")
|
||||
branchOutput, err := branchCmd.Output()
|
||||
if err == nil {
|
||||
currentBranch := string(branchOutput)
|
||||
currentBranch = currentBranch[:len(currentBranch)-1] // trim newline
|
||||
if currentBranch != "main" && currentBranch != "master" {
|
||||
return fmt.Errorf("cannot undock: must be on main branch (currently on %s)\n"+
|
||||
"Undocking on other branches won't persist. Run: git checkout main", currentBranch)
|
||||
}
|
||||
}
|
||||
|
||||
// Get rig and town root
|
||||
_, r, err := getRig(rigName)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user