Skip to content

Instantly share code, notes, and snippets.

@enis-ismail
Last active March 10, 2019 09:57
Show Gist options
  • Save enis-ismail/dbc154f927853a37218860100a64eaf1 to your computer and use it in GitHub Desktop.
Save enis-ismail/dbc154f927853a37218860100a64eaf1 to your computer and use it in GitHub Desktop.
Git hooks: pre-commit
#!/bin/bash
# Instructions to make hooks executable:
#- for Windows (attrib +x pre-commit)
#- for Linux (chmod +x pre-commit)
# ---------------------------------------------------------- #
# Prevent committing changes for files from specific folders #
# ---------------------------------------------------------- #
for SRC_PATTERN in "app_storefront_base" "modules"; do
if git diff --cached --name-only | grep --quiet "$SRC_PATTERN/"; then
echo "Changes in $SRC_PATTERN cartridge are not allowed. If you want to skip the pre-commit hook just add --no-verify: git commit --no-verify"
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment