Only check for the git hooks directory in (un)install subcommands.
This commit is contained in:
parent
91a5cc4203
commit
16757cabce
|
@ -35,12 +35,13 @@ fn main() -> Result<()> {
|
||||||
let config = Config::from_toml_file(args.config)?;
|
let config = Config::from_toml_file(args.config)?;
|
||||||
|
|
||||||
let git_hooks_dir = PathBuf::from(".git/hooks/");
|
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 {
|
match args.command {
|
||||||
MainSubcommands::Install { overwrite } => {
|
MainSubcommands::Install { overwrite } => {
|
||||||
|
if !git_hooks_dir.exists() {
|
||||||
|
return Err(eyre!("The \".git/hooks/\" directory does not exist"));
|
||||||
|
}
|
||||||
|
|
||||||
for hook_type in HOOK_TYPES {
|
for hook_type in HOOK_TYPES {
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
context.insert("hook_type", hook_type);
|
context.insert("hook_type", hook_type);
|
||||||
|
@ -63,6 +64,10 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
MainSubcommands::Uninstall { all } => {
|
MainSubcommands::Uninstall { all } => {
|
||||||
|
if !git_hooks_dir.exists() {
|
||||||
|
return Err(eyre!("The \".git/hooks/\" directory does not exist"));
|
||||||
|
}
|
||||||
|
|
||||||
for hook_type in HOOK_TYPES {
|
for hook_type in HOOK_TYPES {
|
||||||
let hook_path = git_hooks_dir.join(hook_type);
|
let hook_path = git_hooks_dir.join(hook_type);
|
||||||
if !hook_path.exists() {
|
if !hook_path.exists() {
|
||||||
|
|
Loading…
Reference in New Issue