Open glensc opened 2 years ago
I'm currently working around this in the prepare-commit-msg
hook by using a regex along the lines of the following to check the format of any existing basic commit message, which I'll be verifying with commitlint
anyway:
#!/bin/bash
. "$(dirname "$0")/_/husky.sh"
file="$1"
cat "$file" | grep -qE "^(fix|feat)(\(\w+\))?: .{3,72}$" || (exec < /dev/tty && node_modules/.bin/cz --hook || true)
Or, thinking about it, as I'm using commitlint
anyway:
cat "$file" | npx commitlint -q || (exec < /dev/tty && node_modules/.bin/cz --hook || true)
@nevstokes: quote "$file"
to avoid word splitting
@glensc Thanks, nice catch. I've updated my response.
Although maybe not strictly necessary in this case as $file
will be .git/COMMIT_EDITMSG
?
@nevstokes consistency is the key, you quoted "$1"
. Also, if it's an absolute path, you may run into trouble, like you can't change OneDrive root folder, and it's always like: /Users/glen/OneDrive - Organization Name
. and another thing: you never know where your code could end up by someone copying it ;)
Hey guys, I'm looking into this now. I definitely don't like that you're having to interrogate the COMMIT_EDITMSG
outside of commitizen. The regex is especially fragile, notably around the allowed prefixes and optional components to the message (breaking, etc.) but it's a good start.
Thanks @dmwelch, that's great to hear! My regex is very much a quick and dirty stop-gap solution for me.
@dmwelch any news on this? Did you found a solution? Thanks in advance
Hi,
Just to add to this thread: This shortcoming is this only thing preventing me from recommending cz.
Would be great to have this feature. I agree with @garronej, it's a deal breaker for me and my team 😕
With husky setup, the
-m
is lost.I'm a CLI guru, so if I typed
-m
already, it should be used as a base, for example, add the category to it unless missing.currently have to re-type everything with several prompts. kind of slows down the commit process, driving away from the git hook setup.
Husky part: