Skip to content

Conversation

@Byron
Copy link
Collaborator

@Byron Byron commented Nov 26, 2025

Port but branch apply over to non-legacy code, make sure it builds in non-legacy mode as well.

Tasks

  • add CI validation that it now exists in non-legacy builds.
  • add all the tests for the status quo
  • de-'legacy' oplog to be able to use
  • new 'apply' function in but-api
  • make existing tests work
  • fix CI 💢

Next PR

Follow-up on #11236.

@vercel
Copy link

vercel bot commented Nov 26, 2025

@Byron is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the rust Pull requests that update Rust code label Nov 26, 2025
@Byron Byron force-pushed the next2 branch 5 times, most recently from a5260b5 to 23bf02d Compare November 26, 2025 19:05
@Byron Byron requested a review from Copilot November 27, 2025 03:43
Copilot finished reviewing on behalf of Byron November 27, 2025 03:46
Copy link

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

This PR ports the but branch apply command to work without the legacy feature flag, making it compatible with the new single-branch mode. The work involves reorganizing tests, adding CI validation for non-legacy builds, and creating new API functions in but-api.

Key changes:

  • Add new API functions in but-api for branch operations (specifically apply)
  • Restructure and reorganize tests for the branch command into separate files (apply.rs, new.rs)
  • Add CI validation to ensure but builds and tests pass without the legacy feature flag
  • Update Cargo.toml dependencies to properly gate legacy-specific dependencies

Reviewed changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/but/tests/but/utils.rs Make invoke_bash more flexible by accepting impl AsRef<str> instead of &str
crates/but/tests/but/main.rs Gate id and journey test modules with #[cfg(feature = "legacy")]
crates/but/tests/but/command/snapshots/help/no-arg-no-legacy.stdout.term.svg Add new snapshot for help command output in non-legacy mode
crates/but/tests/but/command/mod.rs Gate commit, rub, and status test modules with #[cfg(feature = "legacy")]
crates/but/tests/but/command/help.rs Add non-legacy version of help test and gate existing tests with legacy feature flag
crates/but/tests/but/command/format.rs Gate legacy-specific test code with #[cfg(feature = "legacy")]
crates/but/tests/but/command/branch/new.rs Extract new command tests from the old branch.rs file into separate module
crates/but/tests/but/command/branch/mod.rs Create branch test module structure with gated submodules for apply and new
crates/but/tests/but/command/branch/apply.rs Extract apply command tests from old branch.rs with comprehensive test coverage
crates/but/tests/but/command/branch.rs Remove file - tests moved to separate apply.rs and new.rs files
crates/but/src/args/tests.rs Gate get_gerrit_flags tests with #[cfg(feature = "legacy")]
crates/but-workspace/src/branch/apply.rs Add into_owned() method to Outcome and add documentation about checkout behavior
crates/but-clap/Cargo.toml Remove unused snapbox dev-dependency
crates/but-api/src/lib.rs Add #![deny(missing_docs)] and new branch module for branch operations
crates/but-api/src/legacy/mod.rs Add #![allow(missing_docs)] for legacy code
crates/but-api/src/json.rs Add module documentation and document ToJsonError trait
crates/but-api/src/github.rs Add #![allow(missing_docs)] for GitHub integration code
crates/but-api/src/branch.rs Add new apply and apply_without_oplog functions for branch application
crates/but-api/Cargo.toml Reorganize dependencies to properly gate legacy-specific crates
Cargo.lock Update lock file to reflect removed snapbox dependency from but-clap
.github/workflows/push.yaml Add CI step to test but without default features (non-legacy mode)

@Byron Byron force-pushed the next2 branch 3 times, most recently from a5b2db1 to 67da5d3 Compare November 27, 2025 21:18
@Byron Byron marked this pull request as ready for review November 27, 2025 21:18
@Byron Byron enabled auto-merge November 27, 2025 21:21
@Byron Byron requested a review from Copilot November 27, 2025 21:23
Copilot finished reviewing on behalf of Byron November 27, 2025 21:25
Copy link

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

Copilot reviewed 79 out of 88 changed files in this pull request and generated 4 comments.

Copy link

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

Copilot reviewed 80 out of 89 changed files in this pull request and generated no new comments.

@krlvi
Copy link
Member

krlvi commented Nov 27, 2025

Looks good to me. One thing that i found interesting in the PR title "Single-branch support for but branch apply" - I think I know what you meant but also, per definition the apply function is about adding an additional branch to the workspace, so perhaps 'single branch' may be a misnomer in this case

Copy link
Member

@krlvi krlvi left a comment

Choose a reason for hiding this comment

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

thanks, for this, LGTM

@Byron
Copy link
Collaborator Author

Byron commented Nov 28, 2025

Thanks you!

[..] One thing that i found interesting in the PR title "Single-branch support for but branch apply" - I think I know what you meant but also, per definition the apply function is about adding an additional branch to the workspace, so perhaps 'single branch' may be a misnomer in this case

What if I told you that apply can be used in single branch mode, e.g. while on main, apply a feature branch and it will automatically create a workspace for you. Without target, you will now see main and feature. But if main is configured as target, you will see only feature.

Single-branch mode for me means that all functions work everywhere, or at least have meaningful results or graceful failure if it's just not possible (like unapplying a branch, that really is only for real workspaces, from what I can tell).

This allows us to validate the non-legacy mode as well.
…ble `but-api`

That way we can demonstrate semantics of the oplog/undo system.
While at it, make it clearer from dependencies what's legacy and what not,
similar to the `but` (CLI) crate.
In legacy mode, we can use non-legacy code, but not the other way around.
So let's split it on the highest level. Also, let's not use feature toggles
for the same reason, it's now not possible anymore to call into old code
as it's not available anymore.
@Byron Byron force-pushed the next2 branch 7 times, most recently from 84bc3c6 to 931b52d Compare November 28, 2025 09:33
Ideally, it's clear why tests fail and how to fix them.

- add a cache
- focus the test-runs to only the crates that harbor ts type definitions
- remove CI dependencies as the dependents hang if there was no Rust change, which
  causes the definitions job to not run.
@Byron Byron merged commit 4314abc into gitbutlerapp:master Nov 28, 2025
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants