blt icon indicating copy to clipboard operation
blt copied to clipboard

DX-5101: Git Hooks Incompatible with zsh

Open mikemadison13 opened this issue 3 years ago • 6 comments

Describe the bug The default BLT git hooks (in https://github.com/acquia/blt/tree/main/scripts/git-hooks) explicitly define bash as the scripting engine, which causes them to fail on zsh terminals.

To Reproduce Steps to reproduce the behavior, ideally starting from a fresh install of BLT:

  1. run blt setup to install the hooks
  2. attempt a git commit with the stock git hooks in place (and note failure)

I think that ideally BLT would provide a shell variable that lets us differentiate between bash or zsh hooks and make the path to the hooks dynamic.

mikemadison13 avatar Mar 28 '22 15:03 mikemadison13

@mikemadison13 it shouldn't matter what your default shell is, as long as Bash is installed on your machine. Are you saying that Bash is no longer installed at all on M1 Macs? That would be a massive breaking change, considering half the shell scripts in the world require Bash.

danepowell avatar Apr 11 '22 14:04 danepowell

i'm pretty sure bash is on the machine, but given that my new M1 came pre-configured with ZSH all of the BLT git hooks were failing. i'm open to other ideas, but i think "having" bash and "using" bash could be the disconnect here.

mikemadison13 avatar Apr 11 '22 15:04 mikemadison13

I use ZSH on my non-M1 Mac and have never had an issue with the shell scripts. The whole point of the shebang is to specify the interpreter, it's often not even a shell but NodeJS or PHP. Obviously you don't use PHP as your shell, but PHP scripts defined this way should still run fine 😄

Can you be more specific about the error you're seeing?

danepowell avatar Apr 11 '22 17:04 danepowell

I'll see if I can reproduce, they seem to be working today 🤦

mikemadison13 avatar Apr 12 '22 19:04 mikemadison13

So githooks started failing for me recently. Specially the precommit "Validating commit message syntax". I'm not sure yet how related this might be to any changes done here. But I am using ZSH on my mac on Monterrey version 12.3.1. It seems like the issue is something that was introduced in BLT 13.4 because it works fine on 13.3. What changed that could be stepping on git precommit hooks?

bmartinez287 avatar Jun 14 '22 20:06 bmartinez287