Conversation
|
@Byron is attempting to deploy a commit to the GitButler Team on Vercel. A member of the Team first needs to authorize it. |
05ecfa7 to
f357f93
Compare
Co-authored-by: GPT 5.4 <codex@openai.com>
That way it's clear when mutations happens. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
That way they don't need direct access to data that soon enough won't exist anymore. In theory this can be postponed until no code exists that relies on that data. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
There was a problem hiding this comment.
Pull request overview
This PR continues the “consistent-data” migration by reducing legacy VirtualBranchesHandle/VBH influence in but-api and aligning legacy stack/UI derivation with RefMetadata, while updating callers to accommodate API changes in VirtualBranchesHandle.
Changes:
- Updated
gitbutler_stack::VirtualBranchesHandlewrite-like APIs to take&mut self, and adjusted call sites accordingly across crates and tests. - Refactored legacy stack listing/details (
but-workspace) to derive stack IDs/refs fromRefMetadataworkspace data instead of directly reading TOML-backed metadata structures. - Adjusted
but-apilegacy workspace/rules endpoints to usectx.meta()where possible and to share stack-fetching logic.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| etc/plans/consistent-data.md | Updates migration plan/checklist and adds baseline list for legacy_meta() callers. |
| crates/gitbutler-testsupport/src/lib.rs | Updates test helper to use a mutable VBH handle. |
| crates/gitbutler-stack/tests/mod.rs | Updates tests for new &mut self VBH mutating APIs. |
| crates/gitbutler-stack/src/state.rs | Changes VBH mutating methods to require &mut self. |
| crates/gitbutler-stack/src/stack.rs | Updates stack operations to use mutable VBH handles where needed. |
| crates/gitbutler-oplog/src/oplog.rs | Updates snapshot prepare/restore paths to use mutable VBH. |
| crates/gitbutler-branch-actions/tests/branch-actions/driverless.rs | Updates test setup to use mutable VBH for default target writes. |
| crates/gitbutler-branch-actions/src/virtual.rs | Uses mutable ctx.virtual_branches() handle for operations that update VB state. |
| crates/gitbutler-branch-actions/src/upstream_integration.rs | Updates integration flow to pass mutable VBH into stack head updates. |
| crates/gitbutler-branch-actions/src/undo_commit.rs | Updates undo flow to pass mutable VBH into stack head updates. |
| crates/gitbutler-branch-actions/src/squash.rs | Updates squash flow to pass mutable VBH into stack head updates. |
| crates/gitbutler-branch-actions/src/reorder.rs | Updates reorder flow to pass mutable VBH into stack head updates. |
| crates/gitbutler-branch-actions/src/move_commits.rs | Updates move-commit flow to thread mutable VBH into helper functions. |
| crates/gitbutler-branch-actions/src/move_branch.rs | Updates move-branch flow to thread mutable VBH into helper functions. |
| crates/gitbutler-branch-actions/src/integration.rs | Updates integration verification to pass mutable VBH into stack head updates. |
| crates/gitbutler-branch-actions/src/branch_upstream_integration.rs | Updates upstream integration to use mutable VBH handle. |
| crates/gitbutler-branch-actions/src/branch_manager/branch_removal.rs | Uses mutable VBH for stack state updates and ordering updates. |
| crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs | Uses mutable VBH for default target reads and stack head updates. |
| crates/gitbutler-branch-actions/src/base.rs | Uses mutable VBH for default target bootstrapping/updates. |
| crates/gitbutler-branch-actions/src/actions.rs | Uses mutable VBH where deletion/GC requires VBH writes. |
| crates/but-workspace/src/legacy/tree_manipulation/split_branch.rs | Updates split-branch to pass mutable VBH into stack head updates. |
| crates/but-workspace/src/legacy/stacks.rs | Refactors legacy stacks/details V3 to derive IDs/refs from RefMetadata workspace data. |
| crates/but-workspace/src/legacy/head.rs | Updates remerge helper to use mutable VBH. |
| crates/but-workspace/src/legacy/commit_engine/mod.rs | Updates commit engine path to use mutable VBH. |
| crates/but-api/src/legacy/workspace.rs | Switches some endpoints to ctx.meta() and introduces shared stacks_v3_from_ctx() helper. |
| crates/but-api/src/legacy/rules.rs | Reuses stacks_v3_from_ctx() instead of duplicating stack listing logic. |
| crates/but-action/src/simple.rs | Threads mutable VBH into the “simple” handle-changes flow. |
| crates/but-action/src/lib.rs | Updates helper signature to accept mutable VBH. |
Comments suppressed due to low confidence (1)
crates/gitbutler-stack/src/state.rs:131
VirtualBranchesHandleonly storesfile_pathand none of these methods mutate the handle itself (they only read/write underlying storage). Requiring&mut selfhere is misleading and forces widespreadmutplumbing in callers without adding safety. Consider keeping these APIs as&self(or introduce actual internal mutable state if needed) so read/write operations can be performed through shared references.
/// Persists the default target for the given repository.
///
/// Errors if the file cannot be read or written.
pub fn set_default_target(&mut self, target: Target) -> Result<()> {
let mut virtual_branches = self.read_file()?;
virtual_branches.default_target = Some(target);
self.write_file(&virtual_branches)?;
Ok(())
}
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd92fd1665
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
There was a problem hiding this comment.
Pull request overview
This PR continues the “consistent data” effort by reducing direct dependence on legacy VirtualBranchesHandle/metadata APIs in but-api and shifting legacy stack projections (stacks_v3 / stack_details_v3) to rely on the generic RefMetadata/workspace metadata model. It also updates call sites across the repo to accommodate VirtualBranchesHandle write APIs now requiring &mut self, and adds coverage for a stack-details lookup edge case.
Changes:
- Updated
but-apilegacy workspace endpoints and related callers to usectx.meta()(genericRefMetadata) instead ofctx.legacy_meta(). - Refactored
but-workspacelegacy stack projections to derive stack IDs / stack lookup via workspace metadata instead of TOML-specific access. - Made
VirtualBranchesHandlemutation methods require&mut selfand propagated the necessarymutbindings through call sites; added a regression test for stack-details lookup.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| etc/plans/consistent-data.md | Updates the consistency track plan checklist/notes to reflect current work items. |
| crates/gitbutler-testsupport/src/lib.rs | Adjusts testsupport helper to use a mutable VB handle where it mutates state. |
| crates/gitbutler-stack/tests/mod.rs | Updates stack tests to use mutable VB handles and mutable parameters where required. |
| crates/gitbutler-stack/src/state.rs | Changes VB handle mutation APIs (set_*, write_file, etc.) to require &mut self. |
| crates/gitbutler-stack/src/stack.rs | Updates stack state persistence flows to use mutable VB handles where needed. |
| crates/gitbutler-oplog/src/oplog.rs | Updates oplog snapshot/restore flows to use mutable VB handles for syncing/import. |
| crates/gitbutler-branch-actions/tests/branch-actions/driverless.rs | Adjusts test helper to create a mutable VB handle before mutating default target. |
| crates/gitbutler-branch-actions/src/virtual.rs | Updates branch-action flows to use mutable VB handle where stack metadata is written. |
| crates/gitbutler-branch-actions/src/upstream_integration.rs | Updates upstream integration to pass mutable VB handle into stack head updates. |
| crates/gitbutler-branch-actions/src/undo_commit.rs | Updates undo flow to use mutable VB handle for stack-head updates. |
| crates/gitbutler-branch-actions/src/squash.rs | Updates squash flow to use mutable VB handle for stack-head updates. |
| crates/gitbutler-branch-actions/src/reorder.rs | Updates reorder flow to use mutable VB handle for stack-head updates. |
| crates/gitbutler-branch-actions/src/move_commits.rs | Updates move-commit flow to pass mutable VB handle into destination updates and head updates. |
| crates/gitbutler-branch-actions/src/move_branch.rs | Updates move/tear-off flows to pass mutable VB handle through helpers that mutate stack state. |
| crates/gitbutler-branch-actions/src/integration.rs | Updates integration verification flow to use mutable VB handle when mutating stack head. |
| crates/gitbutler-branch-actions/src/branch_upstream_integration.rs | Updates branch upstream integration to use mutable VB handle for stack-head updates. |
| crates/gitbutler-branch-actions/src/branch_manager/branch_removal.rs | Updates branch removal manager to use a mutable VB handle. |
| crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs | Updates branch creation manager to use mutable VB handle and pass it to stack-head updates. |
| crates/gitbutler-branch-actions/src/base.rs | Updates base-branch/target flows to use mutable VB handle for default target and stack writes. |
| crates/gitbutler-branch-actions/src/actions.rs | Updates actions to use mutable VB handle where deletions/GC mutate VB state. |
| crates/but/src/legacy/commits.rs | Switches CLI legacy projections to use ctx.meta() instead of ctx.legacy_meta(). |
| crates/but/src/command/legacy/mcp_internal/stack.rs | Switches MCP legacy stack details to use ctx.meta() instead of ctx.legacy_meta(). |
| crates/but-workspace/tests/workspace/ref_info/with_workspace_commit/legacy.rs | Adds a regression test covering stack-details lookup via surviving refs (advanced tip case). |
| crates/but-workspace/src/legacy/tree_manipulation/split_branch.rs | Updates split-branch flow to use mutable VB handle when updating stack head. |
| crates/but-workspace/src/legacy/stacks.rs | Refactors legacy stack listing/details to use RefMetadata + workspace metadata for stable IDs/lookups. |
| crates/but-workspace/src/legacy/head.rs | Updates legacy head logic to use a mutable VB handle where stack state is written. |
| crates/but-workspace/src/legacy/commit_engine/mod.rs | Updates commit engine to use a mutable VB handle where VB state is mutated. |
| crates/but-api/src/legacy/workspace.rs | Removes legacy_meta() usage in favor of ctx.meta(); factors stack listing into a shared helper. |
| crates/but-api/src/legacy/rules.rs | Reuses the new stacks_v3_from_ctx() helper to avoid duplicating stack listing logic. |
| crates/but-action/src/simple.rs | Updates action flow to keep a mutable VB handle and pass it through mutation paths. |
| crates/but-action/src/lib.rs | Updates helper signature to accept a mutable VB handle for default-target initialization. |
You can also share your feedback on Copilot code review. Take the survey.
A PR on the data-consistency track, removing VirtualBranchesHandle usage or reducing its influence.
This PR builds back the
stacks_v3hacks that shouldn't be needed anymore thanks to better reconciliation.There is another issue which is documented in a test related to advanced tips - for some reason the WP doesn't pick it up. This wouldn't block this PR as it's not introducing this behaviour, and I am taking a look.
Also,
stack_details_v3can't deal with stacks that have advanced due to the way this is implemented. A follow-up could also attempt to fix that, but it might not be worth it for the Svelte UI.Tasks
but-apiof direct VBH influence