# /simplify: reuse confirmDoctorFix + take repo in PushMigratedCheckpointRefs

`bf27e92`·

Soph·2w ago·2 files·+8 added/-35 removed

- doctor migrate-checkpoints now reuses the existing confirmDoctorFix helper instead of a near-duplicate confirm form — picking up its context-cancellation guard (huh opens the TTY during startup regardless of ctx state) and dropping the huh/errors/context imports.
- PushMigratedCheckpointRefs takes the *git.Repository the command already opened rather than re-opening one, matching the strategy entry-point pattern and removing a redundant repo open per invocation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

## Sessions

01f324c13852View transcript

## Changes

2

- cmd/entire/cli

- Mdoctor_migrate.go+4/-26

- strategy

- Mmanual_commit_push.go+4/-9

```
1
2
3
4
5
4
5
8
6
7
8
60 unmodified lines

69
70
71
75
72
73
74
75
76
77
80
78
79
80
81
84
82
83
84
85
4 unmodified lines

90
91
92
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

package cli

import (
	context
	"errors"
	"fmt"

"charm.land/huh/v2"
	"github.com/spf13/cobra"

"github.com/entireio/cli/cmd/entire/cli/checkpoint"
60 unmodified lines

return nil
	}

confirmed, err := confirmPushMigratedRefs(ctx, len(result.Migrated))
	title := fmt.Sprintf("Push %d migrated checkpoint ref(s) now?", len(result.Migrated))
	confirmed, err := confirmDoctorFix(ctx, out, title)
	if err != nil {
		return err
	}
	if !confirmed {
		fmt.Fprintln(out, "Left queued for the next push.")
		fmt.Fprintln(out, "Refs stay queued for the next push.")
		return nil
	}

pushed, err := strategy.PushMigratedCheckpointRefs(ctx, migrateCheckpointsPushRemote)
	pushed, err := strategy.PushMigratedCheckpointRefs(ctx, repo, migrateCheckpointsPushRemote)
	if err != nil {
		return fmt.Errorf("push migrated refs: %w", err)
	}
4 unmodified lines

cmd.Flags().BoolVar(&dryRun, "dry-run", false, "Report what would be migrated without writing refs")
	return cmd
}

// confirmPushMigratedRefs prompts whether to push the migrated refs now. A user
// abort (or cancelled context) is treated as "no", not an error.
func confirmPushMigratedRefs(ctx context.Context, count int) (bool, error) {
	var confirmed bool
	form := NewAccessibleForm(
		huh.NewGroup(
			huh.NewConfirm().
				Title(fmt.Sprintf("Push %d migrated checkpoint ref(s) now?", count)).
				Value(&confirmed),
			),
		)
	if err := form.RunWithContext(ctx); err != nil {
		if errors.Is(err, huh.ErrUserAborted) || errors.Is(err, context.Canceled) {
			return false, nil
		}
		return false, fmt.Errorf("prompt failed: %w", err)
	}
	return confirmed, nil
}
```

Mcmd/entire/cli/doctor_migrate.go+4/-26

```
172 unmodified lines

173
174
175
176
177
178
179
176
177
178
179
180
181
182
183
184
185
186
187
188
184
185
186

172 unmodified lines

// PushMigratedCheckpointRefs pushes any queued checkpoint refs to the configured
// checkpoint remote, surfacing errors (unlike the fail-soft pre-push path). It is
// the opt-in "push now" invoked by the checkpoint migration command. Returns the
// number of refs pushed. A no-op (0, nil) when pushing is disabled or the queue
// is empty.
func PushMigratedCheckpointRefs(ctx context.Context, remote string) (int, error) {
// the opt-in "push now" invoked by the checkpoint migration command; the caller
// owns the repo. Returns the number of refs pushed — a no-op (0, nil) when
// pushing is disabled or the queue is empty.
func PushMigratedCheckpointRefs(ctx context.Context, repo *git.Repository, remote string) (int, error) {
	ps := resolvePushSettings(ctx, remote)
	if ps.pushDisabled {
		return 0, nil
	}
	repo, err := OpenRepository(ctx)
	if err != nil {
		return 0, fmt.Errorf("open repository: %w", err)
	}
	defer repo.Close()
	return flushCheckpointRefsQueue(ctx, repo, ps.pushTarget())
}
```

Mcmd/entire/cli/strategy/manual_commit_push.go+4/-9
