Skip to content

Instantly share code, notes, and snippets.

@mheob
Created February 8, 2021 15:46
Show Gist options
  • Save mheob/a349b1973da6ef25e928301bfc24359a to your computer and use it in GitHub Desktop.
Save mheob/a349b1973da6ef25e928301bfc24359a to your computer and use it in GitHub Desktop.
100HERZ - Craft CMS - Git Hook - post merge
#!/usr/bin/env bash
# git hook to run a command after `git pull` if a specified file was changed
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
echo "Checking yarn.lock ..."
check_run "yarn.lock" "yarn install"
echo
echo "Checking composer.lock ..."
check_run "composer.lock" "composer install"
echo
echo "Checking cms/composer.lock ..."
check_run "cms/composer.lock" "cd cms && composer install"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment