Switch but status from plumbing head_info to but-api head_info#12756
Switch but status from plumbing head_info to but-api head_info#12756
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
fdfdb26 to
b6b26d1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fdfdb26c43
ℹ️ 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".
Replaces direct but_workspace::head_info() calls with but_api::legacy::workspace::head_info() in the status command, eval_hook, and IdMap. Adapts all IdMap wrapper types to use UI types (ui::Commit, ui::UpstreamCommit, ui::ref_info::Segment/Stack) instead of raw plumbing types. Adds linked_worktree_id field to UI Segment to preserve worktree info through the conversion.
There was a problem hiding this comment.
Pull request overview
This PR refactors the but status command, eval_hook, and IdMap to use UI types from but_workspace::ui instead of raw plumbing types from but_workspace::ref_info and but_workspace::branch. This is part of a progressive migration toward using the shared UI layer (but-api and but_workspace::ui) consistently across the codebase.
Changes:
- Replaces direct
but_workspace::head_info()calls instatus/mod.rswithbut_api::legacy::workspace::head_info(), and adds a two-step conversion ineval_hook.rs - Adapts
IdMapwrapper types (WorkspaceCommitWithId,RemoteCommitWithId,SegmentWithId) to use UI types (ui::Commit,ui::UpstreamCommit,ui::ref_info::Segment/Stack) - Adds
linked_worktree_idfield toui::Segmentto preserve worktree info through the plumbing-to-UI type conversion
Reviewed changes
Copilot reviewed 8 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
crates/but-workspace/src/ui/ref_info.rs |
Adds linked_worktree_id: Option<BString> field to ui::Segment, populated in Segment::for_ui() from ref_info.worktree |
crates/but/src/id/mod.rs |
Updates WorkspaceCommitWithId, RemoteCommitWithId, SegmentWithId to use UI types; adapts accessor methods (state(), branch_name(), linked_worktree_id()) |
crates/but/src/id/stacks_info.rs |
Updates import to use but_workspace::ui::ref_info::Stack |
crates/but/src/id/tests.rs |
Updates test helpers to construct ui::Commit/ui::UpstreamCommit/ui::ref_info::Segment directly |
crates/but/src/command/legacy/status/mod.rs |
Switches to but_api::legacy::workspace::head_info(ctx); adapts commit classification using CommitState; changes date format to RFC3339 |
crates/but/src/command/legacy/status/json.rs |
Removes gix_time_to_rfc3339 helper (superseded by i128_to_rfc3339); populates review_id from gerrit_review_url |
crates/but/src/command/eval_hook.rs |
Adds RefInfo::for_ui() conversion step; uses display_name instead of ref_name.shorten() |
crates/but/tests/but/snapshots/from-workspace/status01-verbose.stdout.term.svg |
Updated snapshot: dimmed opacity and RFC3339 date format |
crates/but/tests/but/command/snapshots/status/two-worktrees/status-with-worktrees-verbose.stdout.term.svg |
Updated snapshot: dimmed opacity and RFC3339 date format |
You can also share your feedback on Copilot code review. Take the survey.
b6b26d1 to
253b928
Compare
| feature = "export-schema", | ||
| schemars(schema_with = "but_schemars::bstring_bytes_opt") | ||
| )] | ||
| pub linked_worktree_id: Option<BString>, |
There was a problem hiding this comment.
@Byron the but CLI uses this linked_worktree_id for some reason. It's not quite clear why it's necessary but i couldn't shed it
There was a problem hiding this comment.
but status actually uses the linked_worktree_id to show if a reference is checked out in a linked worktree, but it's display only:
gitbutler/crates/but/src/command/legacy/status/mod.rs
Lines 621 to 632 in 5793dde
The rebase engine would use this information to update linked worktrees when it changed what a reference points to (right now it's not doing that).
Replaces direct but_workspace::head_info() calls with
but_api::legacy::workspace::head_info() in the status command,
eval_hook, and IdMap. Adapts all IdMap wrapper types to use UI
types (ui::Commit, ui::UpstreamCommit, ui::ref_info::Segment/Stack)
instead of raw plumbing types. Adds linked_worktree_id field to
UI Segment to preserve worktree info through the conversion.