Skip to content

feat(cli): automatically enter workspace from but branch new - #15418

Merged
davidpdrsn merged 2 commits into
masterfrom
dp-cli-single-branch-mode-branch-creation
Aug 21, 2026
Merged

feat(cli): automatically enter workspace from but branch new#15418
davidpdrsn merged 2 commits into
masterfrom
dp-cli-single-branch-mode-branch-creation

Conversation

@davidpdrsn

@davidpdrsn davidpdrsn commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Just but branch new. Still missing the other commands that create new branches like commit and move.

@github-actions github-actions Bot added rust Pull requests that update Rust code CLI The command-line program `but` labels Aug 19, 2026
@davidpdrsn
davidpdrsn force-pushed the dp-cli-single-branch-mode-branch-creation branch 8 times, most recently from 87b6de3 to 4e69af5 Compare August 20, 2026 14:50
I've found this useful while developing because its not clear from the status
itself if you're in SBM or not. When we actually roll out SBM this label can be
removed.
@davidpdrsn
davidpdrsn force-pushed the dp-cli-single-branch-mode-branch-creation branch from 4e69af5 to da222a8 Compare August 20, 2026 15:01
@davidpdrsn
davidpdrsn marked this pull request as ready for review August 20, 2026 15:01
Copilot AI lite review requested due to automatic review settings August 20, 2026 15:01
@davidpdrsn davidpdrsn changed the title feat(cli): automatically enter workspace when creating new branches feat(cli): automatically enter workspace from but branch new Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the but CLI and supporting workspace/TUI logic so that, in single-branch mode, creating additional (unstacked) branches transitions you into workspace mode automatically, while also improving correctness around applying already-applied branches outside a managed workspace.

Changes:

  • Refactors legacy branch new operations and adjusts single-branch-mode behavior to enter workspace mode when creating additional independent branches.
  • Extends workspace branch-apply and reference-creation logic to support single-branch-mode/workspace transitions (including explicit ordering metadata when needed).
  • Updates/expands CLI and legacy TUI tests/snapshots, including an SBM label in the status TUI hot bar.

Reviewed changes

Copilot reviewed 18 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/but/tests/fixtures/scenario/single-branch-mode.sh Adds a dedicated fixture for single-branch-mode scenarios where main and origin/main align.
crates/but/tests/but/command/push.rs Updates expected output snapshot formatting.
crates/but/tests/but/command/pull.rs Adjusts branch creation tests to specify explicit stack relationships (--above).
crates/but/tests/but/command/commit.rs Adjusts branch creation in tests to specify --above for stacking.
crates/but/tests/but/command/branch/new.rs Reworks single-branch-mode branch-new tests and adds coverage for SBM→workspace transitions.
crates/but/src/error.rs Tweaks CliError::into_internal to drop BadInput hints for internal-error conversion.
crates/but/src/command/legacy/status/tui/tests/utils.rs Drops an exclusive guard before App::new to avoid conflicting guard acquisition in tests.
crates/but/src/command/legacy/status/tui/tests/snapshots/shows_single_branch_mode_label_in_hot_bar_001.svg Adds snapshot for SBM label display in the hot bar.
crates/but/src/command/legacy/status/tui/tests/snapshots/marks_spanning_checkouts_are_refused.svg Updates snapshot rendering for revised error box/layout.
crates/but/src/command/legacy/status/tui/tests/snapshots/commit_from_unstaged_changes_to_new_branch_checks_out_branch_in_single_branch_mode_final.svg Updates snapshot to reflect hot bar layout changes and SBM label.
crates/but/src/command/legacy/status/tui/tests/single_branch_mode.rs Adds a TUI test asserting SBM label rendering.
crates/but/src/command/legacy/status/tui/tests/mod.rs Registers the new SBM TUI test module.
crates/but/src/command/legacy/status/tui/render.rs Renders an “SBM” label in the hot bar when in single-branch mode.
crates/but/src/command/legacy/status/tui/app/mod.rs Tracks is_in_single_branch_mode in the TUI App and refreshes it on reload.
crates/but/src/command/legacy/push.rs Switches legacy push handler to CliResult and propagates merged-upstream checks via ?.
crates/but/src/command/legacy/branch/new.rs Refactors new-branch operations (stacked vs unstacked) and implements SBM→workspace entry behavior.
crates/but-workspace/tests/workspace/branch/apply_unapply.rs Updates test helper options to include the new apply option field.
crates/but-workspace/src/branch/create_reference.rs Enhances ad-hoc positioning at workspace base by requiring/persisting branch ordering metadata when necessary.
crates/but-workspace/src/branch/apply.rs Adds allow_applying_already_applied_branch_when_outside_workspace option and updates apply behavior accordingly.
crates/but-debug/src/command/workspace.rs Uses ..Default::default() to pick up new apply options safely.
crates/but-api/src/branch.rs Wires the new apply option into the API call site (defaulting to false).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/but-workspace/src/branch/apply.rs
Comment thread crates/but/src/error.rs
@davidpdrsn
davidpdrsn merged commit 8371392 into master Aug 21, 2026
75 of 76 checks passed
@davidpdrsn
davidpdrsn deleted the dp-cli-single-branch-mode-branch-creation branch August 21, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI The command-line program `but` rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants