Crates.io | patch-crate |
lib.rs | patch-crate |
version | 0.1.10 |
source | src |
created_at | 2023-10-27 13:38:51.067179 |
updated_at | 2024-07-27 08:17:24.040256 |
description | patch-crate lets rust developer instantly make and keep fixes to rust crate dependencies. It's a vital band-aid for those of us living on the bleeding edge. |
homepage | |
repository | https://github.com/mokeyish/cargo-patch-crate |
max_upload_size | |
id | 1016026 |
size | 101,008 |
patch-crate lets rust app developer instantly make and keep fixes to rust crate dependencies. It's a vital band-aid for those of us living on the bleeding edge.
# fix a bug in one of your dependencies
vim target/patch/brokencrate
# run patch-crate to create a .patch file
cargo patch-crate some-crate
# commit the patch file to share the fix with your team
git add patches/some-crate+3.14.15.patch
git commit -m "fix broken_file.rs in some-crate"
Checkout our example at here.
Install command patch-crate
cargo install patch-crate
Add broken crate in your Cargo.toml
[package.metadata.patch]
crates = ["some-crate"]
[patch.crates-io]
some-crate = { path="./target/patch/some-crate-1.0.110" }
Download the crate's source code into target/patch
cargo patch-crate
Fix the broken code in target/patch/some-crate
directly.
Create a crate-patch
cargo patch-crate some-crate
Commit the patch file to share the fix with your team
git add patches/some-crate+1.0.110.patch
git commit -m "fix broken-code in some-crate"
Instead of running cargo patch-crate its also possible to add a build.rs file like this:
fn main() {
println!("cargo:rerun-if-changed=Cargo.toml");
patch_crate::run().expect("Failed while patching");
}
To make it work, add the patch-crate library to the build-dependencies
patch-crate = "0.1"
cargo patch-crate
Apply patch files in ./patches
to ./target/patch/crate-xxx
if it not exist.
cargo patch-crate --force
Clean up ./target/patch/
and apply patch files in ./patches
to ./target/patch/crate-xxx
.
crate patch-crate <crate name1> <crate name2> ...
Create patch file of specific crate from ./target/patch/crate-xxx
and save to ./patches
Licensed under either of
at your option.