Crates.io | cargo-version-sync |
lib.rs | cargo-version-sync |
version | 0.0.5 |
source | src |
created_at | 2018-10-30 07:53:59.58934 |
updated_at | 2018-11-02 16:40:34.321276 |
description | Cargo subcommand for keeping the version numbers in sync with Cargo.toml |
homepage | |
repository | https://github.com/ubnt-intrepid/cargo-prerelease.git |
max_upload_size | |
id | 93539 |
size | 19,025 |
cargo-version-sync
Cargo subcommand for keeping the version numbers in sync with Cargo.toml
Experimental
$ cargo install cargo-version-sync
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
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" }
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
...