Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 130 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "version-control-clean-check"
version = "0.1.3"
version = "0.1.4"
authors = ["One <one.bgz1@gmail.com>"]
categories = []
documentation = "https://docs.rs/version-control-clean-check"
Expand All @@ -16,9 +16,19 @@ description = "Checks if the version control is clean. Based on code from Cargo.
[dependencies]
anyhow = { version = "1.0.94", features = ["backtrace"] }
cargo-util = "0.2.16"
clap = { version = "4.5.23", features = [
"cargo",
"env",
"derive",
"wrap_help",
], optional = true }
git2 = "0.19.0"
thiserror = "2.0.4"
thiserror = "2.0.8"

[dev-dependencies]
rstest = "0.23.0"
strum = { version = "0.26.3", features = ["derive", "strum_macros"] }

[features]
default = []
clap = ["dep:clap"]
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# version-control-clean-check

Checks the status of the version control system.
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).
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).
In cargo it is used as a safety check before possibly destructive changes are done like running `cargo fix`.

# Feature Flags

- clap - Provides clap derives for the options struct

## Display Messages for Errors

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.

## Tests
Expand Down
6 changes: 6 additions & 0 deletions src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ use crate::{VCSError, VCSResult};
use std::path::Path;

/// Stores the options available for calling [`check_version_control`] and controls which checks if any are run
#[cfg_attr(feature = "clap", derive(clap::Args))]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
pub struct CheckOptions {
/// Does not return an error for dirty files nor generate the list of said files
#[cfg_attr(feature = "clap", arg(long))]
pub allow_dirty: bool,

/// This option basically disables checking. If true no checks are done. (Not even if the `path` exists)
#[cfg_attr(feature = "clap", arg(long))]
pub allow_no_vcs: bool,

/// Does not return an error for staged files nor generate the list of said files
#[cfg_attr(feature = "clap", arg(long))]
pub allow_staged: bool,
}

Expand Down
1 change: 1 addition & 0 deletions tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ fn modify_files<P: AsRef<Path>>(path: P, files: &[&str]) -> anyhow::Result<()> {
let mut file = fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(file_name)?;
file.write_all(b"Some text\n")?;
}
Expand Down
Loading