Skip to content

Commit b48dc06

Browse files
authored
Merge pull request #7 from c-git/develop
0.1.4
2 parents 7233460 + be2fc10 commit b48dc06

File tree

5 files changed

+156
-8
lines changed

5 files changed

+156
-8
lines changed

Cargo.lock

Lines changed: 130 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "version-control-clean-check"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
authors = ["One <[email protected]>"]
55
categories = []
66
documentation = "https://docs.rs/version-control-clean-check"
@@ -16,9 +16,19 @@ description = "Checks if the version control is clean. Based on code from Cargo.
1616
[dependencies]
1717
anyhow = { version = "1.0.94", features = ["backtrace"] }
1818
cargo-util = "0.2.16"
19+
clap = { version = "4.5.23", features = [
20+
"cargo",
21+
"env",
22+
"derive",
23+
"wrap_help",
24+
], optional = true }
1925
git2 = "0.19.0"
20-
thiserror = "2.0.4"
26+
thiserror = "2.0.8"
2127

2228
[dev-dependencies]
2329
rstest = "0.23.0"
2430
strum = { version = "0.26.3", features = ["derive", "strum_macros"] }
31+
32+
[features]
33+
default = []
34+
clap = ["dep:clap"]

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# version-control-clean-check
2+
23
Checks the status of the version control system.
3-
Based on [cargo](https://github.com/rust-lang/cargo)'s [`check_version_control`](https://github.com/rust-lang/cargo/blob/4b84887848a31c6f83434cee2135f4fb0e2c9cf3/src/cargo/ops/fix.rs#L146).
4+
Based on [cargo](https://github.com/rust-lang/cargo)'s [`check_version_control`](https://github.com/rust-lang/cargo/blob/4b84887848a31c6f83434cee2135f4fb0e2c9cf3/src/cargo/ops/fix.rs#L146).
45
In cargo it is used as a safety check before possibly destructive changes are done like running `cargo fix`.
56

7+
# Feature Flags
8+
9+
- clap - Provides clap derives for the options struct
10+
611
## Display Messages for Errors
12+
713
Display messages for errors are meant to be human readable and as such are not considered a breaking change if they are changed for clarity.
814

915
## Tests

src/check.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ use crate::{VCSError, VCSResult};
22
use std::path::Path;
33

44
/// Stores the options available for calling [`check_version_control`] and controls which checks if any are run
5+
#[cfg_attr(feature = "clap", derive(clap::Args))]
56
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
67
pub struct CheckOptions {
78
/// Does not return an error for dirty files nor generate the list of said files
9+
#[cfg_attr(feature = "clap", arg(long))]
810
pub allow_dirty: bool,
11+
912
/// This option basically disables checking. If true no checks are done. (Not even if the `path` exists)
13+
#[cfg_attr(feature = "clap", arg(long))]
1014
pub allow_no_vcs: bool,
15+
1116
/// Does not return an error for staged files nor generate the list of said files
17+
#[cfg_attr(feature = "clap", arg(long))]
1218
pub allow_staged: bool,
1319
}
1420

tests/utils/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ fn modify_files<P: AsRef<Path>>(path: P, files: &[&str]) -> anyhow::Result<()> {
171171
let mut file = fs::OpenOptions::new()
172172
.write(true)
173173
.create(true)
174+
.truncate(true)
174175
.open(file_name)?;
175176
file.write_all(b"Some text\n")?;
176177
}

0 commit comments

Comments
 (0)