Skip to content

Switch but status from plumbing head_info to but-api head_info#12756

Open
krlvi wants to merge 1 commit intomasterfrom
status-use-api-head-info
Open

Switch but status from plumbing head_info to but-api head_info#12756
krlvi wants to merge 1 commit intomasterfrom
status-use-api-head-info

Conversation

@krlvi
Copy link
Member

@krlvi krlvi commented Mar 10, 2026

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.

Copilot AI review requested due to automatic review settings March 10, 2026 14:43
@vercel
Copy link

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gitbutler-web Ready Ready Preview, Comment Mar 10, 2026 2:57pm

Request Review

@github-actions github-actions bot added rust Pull requests that update Rust code CLI The command-line program `but` labels Mar 10, 2026
@krlvi krlvi force-pushed the status-use-api-head-info branch from fdfdb26 to b6b26d1 Compare March 10, 2026 14:49
Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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.
Copy link
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

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 in status/mod.rs with but_api::legacy::workspace::head_info(), and adds a two-step conversion in eval_hook.rs
  • Adapts IdMap wrapper types (WorkspaceCommitWithId, RemoteCommitWithId, SegmentWithId) to use UI types (ui::Commit, ui::UpstreamCommit, ui::ref_info::Segment/Stack)
  • Adds linked_worktree_id field to ui::Segment to 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.

feature = "export-schema",
schemars(schema_with = "but_schemars::bstring_bytes_opt")
)]
pub linked_worktree_id: Option<BString>,
Copy link
Member Author

Choose a reason for hiding this comment

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

@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

Copy link
Collaborator

Choose a reason for hiding this comment

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

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:

let workspace = segment
.linked_worktree_id()
.and_then(|id| {
let ws = repo.worktree_proxy_by_id(id.as_bstr())?;
let base = ws.base().ok()?;
let git_dir = gix::path::realpath(repo.git_dir()).ok();
let base = git_dir
.and_then(|git_dir| base.strip_prefix(git_dir).ok())
.unwrap_or_else(|| &base);
format!(" 📁 {base}", base = base.display()).into()
})
.unwrap_or_default();

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).

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.

3 participants