Skip to content

Commit

Permalink
chore: revert to getopts for argument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Scandiravian committed Oct 17, 2021
1 parent 10a1ed8 commit f1f7471
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 270 deletions.
227 changes: 11 additions & 216 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ license = "MIT"
repository = "https://github.com/swellaby/rusty-hook"
readme = "README.md"
edition = "2018"
keywords = [ "hooks", "githook", "git", "hook", "commit" ]
categories = [ "development-tools" ]
keywords = ["hooks", "githook", "git", "hook", "commit"]
categories = ["development-tools"]
exclude = [
".coverage/**",
".testresults/**",
Expand All @@ -32,16 +32,16 @@ exclude = [

[dependencies]
ci_info = "0.14.2"
clap = "3.0.0-beta.4"
toml = "0.5.8"
getopts = "0.2.21"
nias = "0.7.0"
toml = "0.5.8"

[build-dependencies]
ci_info = "0.14.2"
toml = "0.5.8"
nias = "0.7.0"

[badges]
azure-devops = { project = "swellaby/opensource", pipeline = "rusty-hook.linux-pr", build="49" }
azure-devops = { project = "swellaby/opensource", pipeline = "rusty-hook.linux-pr", build = "49" }
codecov = { repository = "swellaby/rusty-hook", branch = "master", service = "github" }
maintenance = { status = "actively-developed" }
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#[path = "src/rusty_hook.rs"]
mod rusty_hook;

use std::env;
use std::process::exit;
use std::{env, vec};

fn main() {
if ci_info::is_ci() {
Expand All @@ -16,7 +16,7 @@ fn main() {
nias::get_file_writer(),
nias::get_file_existence_checker(),
Some(&target_directory),
vec![],
&[],
) {
println!(
"Fatal error encountered during initialization. Details: {}",
Expand Down
2 changes: 1 addition & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn setup_hooks<F, G>(
run_command: F,
write_file: G,
root_directory_path: &str,
hook_file_skip_list: &[&str],
hook_file_skip_list: &[String],
) -> Result<(), String>
where
F: Fn(
Expand Down
2 changes: 1 addition & 1 deletion src/hook_files/hook_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ else
fi

# shellcheck disable=SC2046
rusty-hook run --hook "${hookName}" $([ -z "$gitParams" ] && echo "" || echo "-- $gitParams")
rusty-hook run --hook "${hookName}" "${gitParams}"
handleRustyHookCliResult $? "${hookName}"
4 changes: 2 additions & 2 deletions src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ pub fn create_hook_files<F>(
write_file: F,
root_directory_path: &str,
hooks_directory: &str,
hook_file_skip_list: &[&str],
hook_file_skip_list: &[String],
) -> Result<(), String>
where
F: Fn(&str, &str, bool) -> Result<(), String>,
{
let hook_file_contents = get_hook_file_contents();
for hook in HOOK_NAMES
.iter()
.filter(|h| !hook_file_skip_list.contains(h))
.filter(|h| !hook_file_skip_list.contains(&h.to_string()))
{
let path = get_file_path(root_directory_path, hooks_directory, hook);
if write_file(&path, &hook_file_contents, true).is_err() {
Expand Down
7 changes: 6 additions & 1 deletion src/hooks_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ mod create_hook_files_tests {
assert!(make_executable);
Ok(())
};
let result = create_hook_files(write_file, root_dir, git_hooks, &[EXP_SKIPPED_HOOK]);
let result = create_hook_files(
write_file,
root_dir,
git_hooks,
&[String::from(EXP_SKIPPED_HOOK)],
);
assert_eq!(result, Ok(()));
}
}
Loading

0 comments on commit f1f7471

Please sign in to comment.