Skip to content

romac/cargo-stitch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cargo-stitch

Crates.io Docs.rs CI codecov License

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.

Install

Important

Requires patch (usually preinstalled) and ast-grep (sg) if using ast-grep rules.

Using cargo binstall (recommended, downloads prebuilt binaries):

cargo binstall cargo-stitch

Using cargo install (builds from source):

cargo install cargo-stitch

From GitHub Releases: download a prebuilt binary for your platform, extract, and place it on your PATH.

From source:

git clone https://github.com/romac/cargo-stitch
cd cargo-stitch
cargo install --path .

Usage

cargo stitch build
cargo stitch test
cargo stitch check
# any cargo subcommand works

Stitch files

Place stitch files in stitches/<crate-name>/ at the workspace root:

  • .patch -- unified diff format, applied with patch -p1
  • .yaml / .yml -- ast-grep rule files, applied with ast-grep 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.

Acknowledgements

Inspired by cargo-fixup.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

About

A Cargo subcommand that applies source-level patches and ast-grep rules to workspace crates before compilation.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages