acquia / blt

Acquia's toolset for automating Drupal 8 and 9 development, testing, and deployment.
https://docs.acquia.com/blt/
GNU General Public License v2.0
443 stars 397 forks source link

DX-5101: Git Hooks Incompatible with zsh #4496

Open mikemadison13 opened 2 years ago

mikemadison13 commented 2 years ago

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.

danepowell commented 2 years ago

@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.

mikemadison13 commented 2 years ago

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.

danepowell commented 2 years ago

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?

mikemadison13 commented 2 years ago

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

bmartinez287 commented 2 years ago

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?

AJWAverill commented 3 months ago

BLT Version 13.7.4.0

I have the githook issue also. New Macbook running Sonoma 14.4. Existing project using ddev. Working fine on older machine. I can get the pre-push hook working by changing

"${ROOT_DIR}"/vendor/bin/blt internal:git-hook:execute:pre-push

to

ddev exec blt internal:git-hook:execute:pre-push

In pre commit a similar change has no effect. I still receive the error below.

Untracked files are present, this may impact the validity of pre-commit checks.
env: php: No such file or directory

There are no untracked files.