I am using yorkie 2.0.0, and cannot run any custom shell scripts in my git hooks. My directory structure looks like this:
<project root>
|-- .githooks
| |-- commit-msg
|
|-- package.json
|-- .git
| |-- hooks
| | |-- <all the proper yorkie git hooks files>
| |
| |-- <other .git stuff>
|
|-- <lots of other irrelevant files>
And my package.json has this gitHooks section:
"gitHooks": {
"commit-msg": ".githooks/commit-msg $GIT_PARAMS"
}
The commit-msg
file is definitely executable, this is the ls -l
line:
-rwxr-xr-x 1 dan dan 400 Sep 14 08:51 commit-msg
When I create a commit, I get the following output:
> running commit-msg hook: .githooks/commit-msg $GIT_PARAMS
/bin/sh: 1: .githooks/commit-msg: not found
commit-msg hook failed (add --no-verify to bypass)
I have tried all kinds of different directory structures and it is never found. I have changed my gitHook script in package.json to things like ls .githooks
and the file shows up then.
What is going on? Why can't yorkie find my file?
(I've tagged this with husky because yorkie is a fork of husky with fairly minimal changes and there is no yorkie tag. The issue here is probably not specific to yorkie)
Turns out the not found
was a red herring. This was a line endings issue.
After I converted the line endings inside commit-msg
to LF, everything worked. I added the following line to my .gitattributes
so this wouldn't keep happening every time I checked out a branch:
.githooks/* text eol=lf