Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(args): mutually exclusive hook and all #121

Merged
merged 1 commit into from
Dec 17, 2024
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
3 changes: 2 additions & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ struct Args {

#[arg(
long,
help = "Run as a git hook, writing the commit message to COMMIT_EDITMSG instead of committing"
help = "Run as a git hook, writing the commit message to COMMIT_EDITMSG instead of committing",
conflicts_with = "all"
)]
hook: bool,

Expand Down
17 changes: 17 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,23 @@ fn test_empty_repository_error() -> Result<(), Box<dyn Error>> {
Ok(())
}

#[test]
fn test_all_hook_exclusive_error() -> Result<(), Box<dyn Error>> {
let bin_path = assert_cmd::cargo::cargo_bin("koji");

let mut cmd = Command::new(bin_path);
cmd.arg("--hook");
cmd.arg("--all");

let cmd_out = cmd.output()?;
let stderr_out = String::from_utf8(cmd_out.stderr)?;

assert!(!cmd_out.status.success());
assert!(stderr_out.contains("the argument '--hook' cannot be used with '--all'"));

Ok(())
}

#[test]
fn test_completion_scripts_success() -> Result<(), Box<dyn Error>> {
fn run_for(shell: &'static str, containing: &'static str) -> Result<(), Box<dyn Error>> {
Expand Down
Loading