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:
- The init prompt now leads with "Warning:" so a wrong-directory run reads as the warning it is.
- Creating the GitHub repo and pushing to it are now separate guards. Even after opting into creating the repo, publishing the directory's contents requires its own confirmation (default No). Declining leaves the repo created with origin configured but nothing pushed, and prints the manual
git push -u origin HEADnext step.
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
cmd/entire/cli
Msetup_github.go+67/-15
Msetup_github_test.go+80/-33
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) {
...
}