5 releases
Uses old Rust 2015
0.0.5 | Nov 2, 2018 |
---|---|
0.0.4 | Nov 1, 2018 |
0.0.3 | Oct 31, 2018 |
0.0.2 | Oct 30, 2018 |
0.0.1 | Oct 30, 2018 |
#506 in Cargo plugins
18KB
388 lines
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
:
[[package.metadata.version-sync.replacements]]
file = "README.md"
replacers = [
{ type = "builtin", target = "markdown" },
{ type = "regex", search = "https://deps.rs/crate/{{name}}/[a-z0-9\\.-]+", replace = "https://deps.rs/crate/{{name}}/{{version}}" },
]
[[package.metadata.version-sync.replacements]]
file = "src/lib.rs"
replacers = [
{ type = "builtin", target = "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
.
[package.metadata.version-sync]
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]
:
[dev-dependencies]
cargo-version-sync = { version = "0.0.2", default-features = false }
Then, add a test case in your integration test as follows:
extern crate cargo_version_sync;
#[test]
fn test_version_sync() {
cargo_version_sync::assert_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
...
Alternatives
License
Dependencies
~3.5–6MB
~101K SLoC