Skip to content

support multiple branches during init#91

Merged
skarim merged 4 commits into
skarim/rm-mergefrom
skarim/init-revamp
May 15, 2026
Merged

support multiple branches during init#91
skarim merged 4 commits into
skarim/rm-mergefrom
skarim/init-revamp

Conversation

@skarim
Copy link
Copy Markdown
Collaborator

@skarim skarim commented May 14, 2026

Revamp gh stack init onboarding experience

Redesign the init flow to be more intuitive for first-time users: implicit branch adoption, automatic prefix detection, a simplified interactive flow, and scenario-aware post-init output.

Changes

  • Implicit adopt (cmd/init.go): Existing branches are now adopted automatically when passed as args — no flag needed. Missing branches are created. Two-pass validation ensures no branches are created if a later arg fails.
  • Prefix detection: Drop the upfront "Set a branch prefix?" prompt. Prefix is now derived from branch names using last-slash split (e.g. feat/a feat/b → prefix feat). Interactive path confirms with Y/n; args path sets it silently.
  • Interactive flow: Print a hint about multi-branch args. On a non-trunk branch, show a Select prompt ("Use current branch" / "Create new"). On trunk, prompt for branch name directly.
  • "What's next" output: Replace the 2-line post-init message with a scenario-aware block — fresh stacks show add/view/submit tips; adopted stacks show view/up/down/submit tips with PR count.
  • Deprecate --adopt: Flag is hidden but still accepted. Prints a warning: "The --adopt flag is deprecated."
  • Docs: Remove all --adopt references from README, CLI reference, FAQ, SKILL.md. Add "Turning Existing Branches into a Stack" section to workflows guide.

Stack created with GitHub Stacks CLIGive Feedback 💬

@skarim skarim marked this pull request as ready for review May 14, 2026 22:15
Copilot AI review requested due to automatic review settings May 14, 2026 22:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Revamps gh stack init to better support first-time onboarding and multi-branch initialization by implicitly adopting existing branches, detecting prefixes from branch names, simplifying the interactive flow, and improving post-init guidance.

Changes:

  • Makes branch adoption implicit when branches already exist; creates missing branches with two-pass validation for arg parsing.
  • Adds automatic prefix detection (from branch names) and updates interactive prompts accordingly; deprecates and hides --adopt.
  • Reworks post-init output into a scenario-aware “What’s next” block and updates docs/examples across guides and references.
Show a summary per file
File Description
skills/gh-stack/SKILL.md Updates init examples to remove --adopt and document multi-branch init/adoption.
README.md Refreshes gh stack init docs to describe implicit adoption and prefix detection.
internal/git/mock_ops.go Re-indents MockOps fields (formatting/consistency).
docs/src/content/docs/reference/cli.md Updates CLI reference text/examples to remove --adopt and reflect new behavior.
docs/src/content/docs/guides/workflows.md Adds a new section explaining how to turn existing branches into a stack via init.
docs/src/content/docs/faq.md Updates FAQ examples to remove --adopt and reflect the new workflow.
cmd/init.go Implements new init flow: implicit adopt/create, prefix detection, deprecated --adopt, PR detection, and new output block.
cmd/init_test.go Updates/expands tests for new init behaviors (implicit adopt, prefix detection, “what’s next” output).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

cmd/init.go:483

  • printWhatsNext prints Adopted %d branches using len(branches) whenever hasAdopted is true, even for mixed cases where some branches were newly created. This can mislead users about what actually happened. Consider adjusting the message to distinguish adopted vs created counts (or use more neutral wording like “Initialized stack” with a breakdown).
	// Success line
	if hasAdopted {
		cfg.Successf("Adopted %d %s: %s",
			len(branches), plural(len(branches), "branch", "branches"), chain)
	} else {
		cfg.Successf("Created stack: %s", chain)
	}
  • Files reviewed: 7/8 changed files
  • Comments generated: 2

Comment thread cmd/init.go
Comment thread cmd/init.go
@skarim skarim force-pushed the skarim/init-revamp branch from c85384a to 6692218 Compare May 14, 2026 22:24
@skarim skarim force-pushed the skarim/rm-merge branch 2 times, most recently from 2c85e59 to 35b0889 Compare May 14, 2026 22:24
@skarim skarim force-pushed the skarim/init-revamp branch from 6692218 to 3854aa2 Compare May 14, 2026 22:24
@skarim skarim force-pushed the skarim/rm-merge branch from 35b0889 to 56eea17 Compare May 14, 2026 22:55
@skarim skarim force-pushed the skarim/init-revamp branch from d1f6674 to 6f6a077 Compare May 14, 2026 22:55
Copy link
Copy Markdown

@ktravers ktravers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a fairly big PR to review, but the thorough, well organized and well described test coverage makes me confident to approve 😄

These changes also seem incredibly user-friendly and helpful, excited for folks to try them out!

@skarim skarim force-pushed the skarim/rm-merge branch from 56eea17 to 1b43b7e Compare May 15, 2026 14:18
@skarim skarim force-pushed the skarim/init-revamp branch from 6f6a077 to 0706796 Compare May 15, 2026 14:18
@skarim skarim merged commit d115ca0 into main May 15, 2026
9 checks passed
@skarim skarim deleted the skarim/init-revamp branch May 15, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants