Skip to content

Commit

Permalink
Fixes acquia#4496 to make a zsh version of git hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Madison committed Mar 28, 2022
1 parent c7495dc commit c147f48
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
7 changes: 5 additions & 2 deletions config/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@ drush:
dir: ${docroot}
sanitize: true

# Valid options are bash or zsh to support git hooks for both shells.
shell: bash

git:
# The value of a hook should be the file path to a directory containing an
# executable file named after the hook. Changing a hook value to 'false' will disable it.
# You should execute `blt blt:init:git-hooks` after modifying these values.
hooks:
pre-commit: ${blt.root}/scripts/git-hooks
pre-push: ${blt.root}/scripts/git-hooks
pre-commit: ${blt.root}/scripts/git-hooks/${shell}
pre-push: ${blt.root}/scripts/git-hooks/${shell}
commit-msg: ${blt.root}/scripts/git-hooks
commit-msg:
# Commit messages must conform to this pattern.
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions scripts/git-hooks/bash/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env zsh

ROOT_DIR="$(pwd)/"

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

# Return the status of the last run command.
exit $?
11 changes: 11 additions & 0 deletions scripts/git-hooks/zsh/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env zsh

ROOT_DIR="$(pwd)/"
LIST=$( git diff --name-only --cached --diff-filter=ACM )

echo "Executing .git/hooks/pre-commit..."
git diff-index --quiet HEAD -- || echo "Untracked files are present, this may impact the validity of pre-commit checks."
"${ROOT_DIR}"/vendor/bin/blt internal:git-hook:execute:pre-commit "${LIST}"

# Return the status of the last run command.
exit $?
File renamed without changes.

0 comments on commit c147f48

Please sign in to comment.