Skip to content

refactor(xtask): share baseline file reading and writing - #188

Merged
kirillDevPro merged 2 commits into
masterfrom
lane/refactor-2026-11-29
Nov 29, 2026
Merged

kirillDevPro merged 2 commits into
masterfrom
lane/refactor-2026-11-29

Conversation

@kirillDevPro

Copy link
Copy Markdown
Collaborator

Refactor lane.

Signal: duplicated logic. component-api and component-mirror each
carried a private read_baseline (read the file with a "read
; run cargo xtask <command> --update-baseline first" context,
then parse JSON with a "parse " context) and an inline
update-baseline block in run (create the parent directory, pretty-
print the report, write it with one trailing newline):

  • xtask/src/component_api.rs:100 (read) and :50 (write)
  • xtask/src/component_mirror.rs:103 (read) and :68 (write)
    Both now call read_baseline / write_baseline in the new
    xtask/src/baseline.rs, which keeps every message byte-identical by
    taking the per-command what and command words. The third copy in
    xtask/src/component_audit.rs is left alone: the lane touched that file
    within the last 60 days.

Lines: component_api.rs 349 -> 335, component_mirror.rs 471 -> 459,
plus a 35-line baseline.rs and one mod line in main.rs.

Tests: xtask/tests/baseline_files.rs, committed before this change and
unchanged by it, drives the real binary for both commands: the
update-baseline file equals the --json report plus one newline with
parent directories created, a missing baseline names its command, a
malformed one reports parse <path>. Re-run with
cargo test -p xtask, then
cargo xtask component-api --check-baseline and
cargo xtask component-mirror --donor-root vendor/longbridge-gpui-component-ui-src --check-baseline.

Reviewer: Codex. Its only finding was that an opt-in
RUST_LIB_BACKTRACE trace now names the shared helper's frame; messages,
exit status, ordering and output bytes are unchanged.

Pins, through the real xtask binary, how component-api and
component-mirror write `--update-baseline` (the `--json` report plus
one trailing newline, parent directories created) and how
`--check-baseline` reports a missing baseline (the per-command hint)
and a malformed one (`parse <path>`).
Refactor lane.

Signal: duplicated logic. component-api and component-mirror each
carried a private `read_baseline` (read the file with a "read <what>
<path>; run `cargo xtask <command> --update-baseline` first" context,
then parse JSON with a "parse <path>" context) and an inline
update-baseline block in `run` (create the parent directory, pretty-
print the report, write it with one trailing newline):
- xtask/src/component_api.rs:100 (read) and :50 (write)
- xtask/src/component_mirror.rs:103 (read) and :68 (write)
Both now call `read_baseline` / `write_baseline` in the new
xtask/src/baseline.rs, which keeps every message byte-identical by
taking the per-command `what` and `command` words. The third copy in
xtask/src/component_audit.rs is left alone: the lane touched that file
within the last 60 days.

Lines: component_api.rs 349 -> 335, component_mirror.rs 471 -> 459,
plus a 35-line baseline.rs and one `mod` line in main.rs.

Tests: xtask/tests/baseline_files.rs, committed before this change and
unchanged by it, drives the real binary for both commands: the
update-baseline file equals the `--json` report plus one newline with
parent directories created, a missing baseline names its command, a
malformed one reports `parse <path>`. Re-run with
`cargo test -p xtask`, then
`cargo xtask component-api --check-baseline` and
`cargo xtask component-mirror --donor-root vendor/longbridge-gpui-component-ui-src --check-baseline`.

Reviewer: Codex. Its only finding was that an opt-in
RUST_LIB_BACKTRACE trace now names the shared helper's frame; messages,
exit status, ordering and output bytes are unchanged.
@kirillDevPro
kirillDevPro merged commit 86ff931 into master Nov 29, 2026
4 checks passed
@kirillDevPro
kirillDevPro deleted the lane/refactor-2026-11-29 branch November 29, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant