cargo-version-sync
Cargo subcommand for keeping the version numbers in sync with Cargo.toml
Status
Experimental
Installation
$ cargo install cargo-version-sync
Usage
At first, add fields to Cargo.toml
for specifying files to rewrite the version numbers by cargo version-sync
:
[[]]
= "README.md"
= [
{ = "builtin", = "markdown" },
{ = "regex", = "https://deps.rs/crate/{{name}}/[a-z0-9\\.-]+", = "https://deps.rs/crate/{{name}}/{{version}}" },
]
[[]]
= "src/lib.rs"
= [
{ = "builtin", = "html-root-url" },
]
Then run the command cargo version-sync
to rewrite version numbers:
$ cargo version-sync
Using Preset
You can use the preset replacers by setting the key use-preset
.
[]
= true
Currently, replacers are registered for the following files:
file = "README.md"
{ type = "builtin", target = "markdown" }
{ type = "regex", search = "https://deps.rs/crate/{{name}}/[0-9a-z\\.-]+", replace = "https://deps.rs/crate/{{name}}/{{version}}" }
file = "src/lib.rs"
{ type = "builtin", target = "html-root-url" }
Integration test
cargo-version-sync
can also be used as a library used in integration tests.
First, add the dependency to the member of [dev-dependencies]
:
[]
= { = "0.0.2", = false }
Then, add a test case in your integration test as follows:
extern crate cargo_version_sync;
When there are some files that have not updated the version numbers, the integration test fails as follows:
$ cargo test
...
running 1 test
test test_version_sync ... FAILED
failures:
---- test_version_sync stdout ----
The version number(s) are not synced in the following files:
- README.md
...