tidy watcher by klensy · Pull Request #114209 · rust-lang/rust (original) (raw)

MVP of tidy watcher:

Allows to check that changes to some pieces of text synced in different files (or at least warn about it). Should resolve situations like: "Oh no, I've changed that constant here and here, but forgot to update it in other 3 places."

Current state is very MVP'ish, so it simply works and nothing more, posted to get some feedback.

Usage: wrap text that need to be synced with arbitrarily chosen tags:

some.rs:

// tidy-keep-sync-with=tidy-ticket-foo const FOO: usize = 42; // tidy-keep-sync-with=tidy-ticket-foo

some.sh:

tidy-keep-sync-with=tidy-ticket-foo

export FOO=42

tidy-keep-sync-with=tidy-ticket-foo

and add them to watcher.rs in tidy, adding into one group:

add_group!(
    ("src/tools/opt-dist/src/main.rs", "728c2783154a52a30bdb1d66f8ea1f2a", "tidy-ticket-perf-commit"),
    ("src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile", "76c8d9783e38e25a461355f82fcd7955", "tidy-ticket-perf-commit")
),

If hashes differs, actual and expected ones will be printed:

tidy error: The code blocks tagged with tidy watcher has changed.
It's likely that code blocks with the following tags need to be changed too. Check src/tools/tidy/src/watcher.rs, find t
ag/hash in TIDY_WATCH_LIST list and verify that sources for provided group of tags in sync. Once that done, run tidy aga
in and update hashes in TIDY_WATCH_LIST with provided actual hashes.
tidy error: hash for tag `tidy-ticket-sess-time-item_types_checking` in path `compiler/rustc_hir_analysis/src/lib.rs` mi
smatch:
  actual: `842e23fb65caf3a96681686131093316`, expected: `842e23fb65caf3a96681686131093317`
  Verify that tags `["tidy-ticket-sess-time-item_types_checking", "tidy-ticket-sess-time-item_types_checking"]` in sync.

Added few sync me commented code as examples.

--bless implemented, but i don't like current json config, it's huge.

r? @ghost