Repository: rhysd/cargo-husky (language: rust)

Issue:
No warning if a hook is not marked as executable
I was getting the following error until I remembered to mark the hook as executable.
```
Error: User hooks directory is not found or empty: ...
```

A warning or clearer error message would be nice :)


Discussion / hints:
Please describe exact steps to reproduce this. Did you use `user-hooks`? In the case, cargo-husky does not care which file is for hook because cargo-husky does not know hook file names. It just copies executable files to `.git/hooks` and I think it should be intended behavior. Otherwise, we need to  maintain names of hook files of Git. But it's hard because it's up to Git version.
Sorry, I wasn't clear.

If you clone this repo: https://github.com/chocol4te/husky-issue and run `cargo test`, the expected behaviour is that the pre-commit hook in `.cargo-husky/hooks` folder is copied to `.git/hooks`, instead I get the following:

```
   Compiling cargo-husky v1.4.0
   Compiling husky-issue v0.1.0 ({path_to_repo}/husky-issue)
error: failed to run custom build command for `cargo-husky v1.4.0`
process didn't exit successfully: `{path_to_repo}/husky-issue/target/debug/build/cargo-husky-a19a1300231c7d87/build-script-build` (exit code: 1)
--- stderr
Error: User hooks directory is not found or empty: "{path_to_repo}/husky-issue/.cargo-husky/hooks"
```

The error is unclear because the directory is definitely not empty, it just contains invalid hooks.
```
$ ls .cargo-husky/hooks
pre-commit
```
Your point is that error message is unclear, am I correct? If so, I think we can improve the error message something like

```
Error: User hooks directory is not found or no executable file is found in the directory. Did you forget making hook script executable?
```

My point is cargo-husky does not know which file is for hook and which is not for hook. It regards executable file as hook script without checking file name. So, for example, let's say we have two hooks `pre-commit` and `pre-push` scripts in hooks directory and forgot adding executable attribute to `pre-push`. In the case, cargo-husky only copies `pre-commit` file. Missing `pre-push` is not detectable.
Yes, that looks great :)

I can open a PR to change it?


Of course. Thank you.

Fix patch:
diff --git a/build.rs b/build.rs
index d761b98..3f8eaab 100644
--- a/build.rs
+++ b/build.rs
@@ -39,8 +39,8 @@ impl fmt::Debug for Error {
             Error::OutDir(env::VarError::NotPresent) => unreachable!(),
             Error::OutDir(env::VarError::NotUnicode(msg)) => msg.to_string_lossy().to_string(),
             Error::InvalidUserHooksDir(path) => {
-                format!("User hooks directory is not found or empty: {:?}", path)
-            }
+                format!("User hooks directory is not found or no executable file is found in '{:?}'. Did you forget to make a hook script executable?", path)
+	        }
             Error::EmptyUserHook(path) => format!("User hook script is empty: {:?}", path),
         };
         write!(f, "{}", msg)


Test patch:
diff --git a/test/test.rs b/test/test.rs
index 8251697..f0df543 100644
--- a/test/test.rs
+++ b/test/test.rs
@@ -437,7 +437,7 @@ fn assert_user_hooks_error(root: &Path) {
             out
         ),
         Err(err) => assert!(
-            format!("{}", err).contains("User hooks directory is not found or empty"),
+            format!("{}", err).contains("User hooks directory is not found or no executable file is found in"),
             "Unexpected output on `cargo test`: {}",
             err
         ),