fix(enable): add separate default-No push guard and warn prefix · Entire

fix(enable): add separate default-No push guard and warn prefix

fd63242→main·

computermode·1w ago·2 files·+147 added/-48 removed

Split the outward-facing steps of the non-repo bootstrap into independent, default-No confirmations so opting into one no longer implies the next:

ghRepoCreate's final parameter now means "push" rather than "hasCommits"; the finalize step passes committed && state.push.

Tests: default-No guards for all three prompts and a finalize test that the push is skipped (repo still created) when the push decision is No. Folded the TTY/accessible env setup into a shared withInteractivePromptStdin helper and migrated the existing resolveRepoName prompt test onto it.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Sessions

01KX72QKGQG59DCXM69SPTM3N5View transcript

Changes

2

117 unmodified lines
// runGitHubBootstrapInit handles the pre-setup half of "enable on a non-git  
// repository, allowing non-cloud setups to enable this by default.  
// setup needs to wait for the resolution of the repo name before running their bootstrap.  
// The process also reproduces a standard bootstrapping phrase in a user-friendly way.  
// The entire process is strictly non-interactive, as it does not read input or prompt for anything.  
// All confirmation prompts are therefore gated on interactive.CanPromptInteractively.  
return &bootstrapState{  
        ...  
}

// confirmPushToRemote asks the user whether to push the initial commit to // the newly-created GitHub repository. Interactive-only; callers gate on // interactive.CanPromptInteractively.

// Defaults to No: pushing publishes the directory's contents to the remote, // a distinct outward-facing action from creating the repo, so it must never // happen just because the user pressed Enter. Declining leaves the repo // created with origin configured but nothing pushed.

func confirmPushToRemote(fullName string) (bool, error) {
confirmed := false
form := NewAccessibleForm(
huh.NewGroup(
huh.NewConfirm().
Title(fmt.Sprintf("Push the initial commit to %s?", fullName)).
Value(&confirmed),
),
)
if err := form.Run(); err != nil {
if errors.Is(err, huh.ErrUserAborted) {
return false, errBootstrapInterrupted
}
return false, fmt.Errorf("push confirm prompt: %w", err)
}
return confirmed, nil
}

// confirmInitRepo returns true if we should proceed with git init. It // respects --init-repo / --no-init-repo; otherwise prompts. In // non-interactive mode we return false without printing anything so

... (truncated) ...

// TestConfirmInitRepo_ExplicitYesProceeds verifies an explicit "y" still // opts in, so the safer default doesn't block intentional use. unc TestConfirmInitRepo_ExplicitYesProceeds(t *testing.T) {
t.Setenv("ENTIRE_TEST_TTY", "1") t.Setenv("ACCESSIBLE", "1") withPipedStdin(t, "y\n") withInteractivePromptStdin(t, "y\n")

proceed, err := confirmInitRepo(io.Discard, t.TempDir(), GitHubBootstrapOptions{}) if err != nil {
// error handling logic } }

// restores the cwd for tests. func restoreCwd(t *testing.T, dir string) {
...
}