Closed VanTanev closed 3 weeks ago
Wait, this is actually much worse than I thought!
If a title contains a dot, the command isn't even executed at all!
# lefthook.yml
pre-commit:
"if title contains a dot. this always passes!":
run: exit 1
➜ pnpm lefthook run pre-commit
╭──────────────────────────────────────╮
│ 🥊 lefthook v1.8.2 hook: pre-commit │
╰──────────────────────────────────────╯
sync hooks: ✔️ (pre-commit, post-merge, _shared_, post-checkout, post-rewrite)
┃ if title contains dot ❯
────────────────────────────────────
summary: (done in 0.02 seconds)
✔️ if title contains dot
➜ $?
zsh: command not found: 0
Hey! Yes, this is a side effect of using viper
package. It considers dot as a short syntax for YAML nesting:
some.nested.option:
value: true
is the same as
some:
nested:
option:
value: true
But this is YAML syntax, and there's (probably) nothing to do with it. Right now I'm working on a slightly different way to configure lefthook. It solves this issue because it doesn't use keys for command names.
...I really hate YAML.
If you're changing the config format, it might be worth considering support for different config format. Even JSON is preferable, YAML has so many edge cases.
Actually lefthook supports JSON and TOML. Do lefthook dump --format=json
for migration :)
Thanks!
I think this issue can be closed. Maybe the most we could do is add a warning to the docs?
:wrench: Summary
If a command title contains a dot (
.
), everything after the dot is omitted in lefthook output:Lefthook version
1.8.2 9996e0d9db43a6b856074d2b836adf924a24b992
Steps to reproduce
Expected results
Actual results
Logs / Screenshots