From 16757cabcef5f5f583773feac2e34148d17a65cd Mon Sep 17 00:00:00 2001 From: Bauke Date: Mon, 31 Oct 2022 14:22:49 +0100 Subject: [PATCH] Only check for the git hooks directory in (un)install subcommands. --- hooked-cli/source/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hooked-cli/source/main.rs b/hooked-cli/source/main.rs index bb7bb71..7596da4 100644 --- a/hooked-cli/source/main.rs +++ b/hooked-cli/source/main.rs @@ -35,12 +35,13 @@ fn main() -> Result<()> { let config = Config::from_toml_file(args.config)?; let git_hooks_dir = PathBuf::from(".git/hooks/"); - if !git_hooks_dir.exists() { - return Err(eyre!("The \".git/hooks/\" directory does not exist")); - } match args.command { MainSubcommands::Install { overwrite } => { + if !git_hooks_dir.exists() { + return Err(eyre!("The \".git/hooks/\" directory does not exist")); + } + for hook_type in HOOK_TYPES { let mut context = Context::new(); context.insert("hook_type", hook_type); @@ -63,6 +64,10 @@ fn main() -> Result<()> { } MainSubcommands::Uninstall { all } => { + if !git_hooks_dir.exists() { + return Err(eyre!("The \".git/hooks/\" directory does not exist")); + } + for hook_type in HOOK_TYPES { let hook_path = git_hooks_dir.join(hook_type); if !hook_path.exists() {