A Cargo subcommand that applies source-level patches and ast-grep rules to workspace crates before compilation.
It intercepts rustc invocations via RUSTC_WORKSPACE_WRAPPER, copies crate sources to target/cargo-stitch/<pkg>/, applies patches and ast-grep rules from stitches/<pkg>/, then compiles the patched sources.
cargo install --path .
Requires patch (usually preinstalled) and ast-grep (sg) if using ast-grep rules.
cargo stitch build
cargo stitch test
cargo stitch check
# any cargo subcommand works
Place stitch files in stitches/<crate-name>/ at the workspace root:
.patch-- unified diff format, applied withpatch -p1.yaml/.yml-- ast-grep rule files, applied withsg scan -r <rule> --update-all
All stitch files are applied in filename order regardless of type. Use numeric prefixes for ordering:
stitches/
some-crate/
001-fix-thing.patch
002-rename-fn.yaml
If no stitches/<crate-name>/ directory exists for a crate, it compiles normally.
Inspired by cargo-fixup.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.