Only check for the git hooks directory in (un)install subcommands.

This commit is contained in:
Bauke 2022-10-31 14:22:49 +01:00
parent 91a5cc4203
commit 16757cabce
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 8 additions and 3 deletions

View File

@ -35,12 +35,13 @@ fn main() -> Result<()> {
let config = Config::from_toml_file(args.config)?;
let git_hooks_dir = PathBuf::from(".git/hooks/");
match args.command {
MainSubcommands::Install { overwrite } => {
if !git_hooks_dir.exists() {
return Err(eyre!("The \".git/hooks/\" directory does not exist"));
}
match args.command {
MainSubcommands::Install { overwrite } => {
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() {