affects
August 4, 2026 · View on GitHub
Forces linked blocks to be edited together. If you change this block and leave the block it points at untouched, the run fails.
Syntax
| Attribute | Value | Default |
|---|---|---|
affects | file:name, or :name for the same file | — |
Separate multiple targets with commas:
// <block affects="README.md:supported-langs, docs/api.md:languages">
Example
src/lib.rs:
// <block affects="README.html:supported-langs">
pub enum Language {
Rust,
Python,
}
// </block>
README.html:
<!-- <block name="supported-langs"> -->
<ul>
<li>Rust</li>
<li>Python</li>
</ul>
<!-- </block> -->
Modify the enum and BlockWatch fails until you also touch supported-langs in README.html.
Direction
affects is one-way. The example above catches "code changed, docs didn't" — but not the reverse. For two-way drift
detection, name both blocks and point each at the other:
// <block name="languages-code" affects="README.html:supported-langs">
<!-- <block name="supported-langs" affects="src/lib.rs:languages-code"> -->
Notes
- Diff mode only. Without a diff on stdin every block counts as unmodified, so
affectscan never fire. Pipegit diff --patch | blockwatchto use it. If you want a check that also works on a full-tree run, usesame-as. - Co-editing, not agreement.
affectsonly checks that both sides were touched — it does not compare their contents. Touching the target with an unrelated edit satisfies it. When the two blocks should hold the same value,same-asis the stronger check. - Missing targets are violations. A reference to a
namethat does not exist is reported. - Targets are read, not reported. Under a diff, a target the diff did not touch is still resolved and compared, but
it does not appear in a
--verbosityrun report. See Reports Under a Diff. - Combining
affectswithcheck-luagives a script access to the affected blocks' contents throughctx.affects, which is a way to compare them without file IO.
← Validators · README