Repository navigation
refactor(xtask): share baseline file reading and writing - #188
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-baselinefirst" 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):
Both now call
read_baseline/write_baselinein the newxtask/src/baseline.rs, which keeps every message byte-identical by
taking the per-command
whatandcommandwords. The third copy inxtask/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
modline 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
--jsonreport plus one newline withparent directories created, a missing baseline names its command, a
malformed one reports
parse <path>. Re-run withcargo test -p xtask, thencargo xtask component-api --check-baselineandcargo 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.