Skip to content

Instantly share code, notes, and snippets.

@coderabbi
Created December 18, 2017 11:26
Show Gist options
  • Save coderabbi/e9dc529cd6e9054166af7762bc9faad0 to your computer and use it in GitHub Desktop.
Save coderabbi/e9dc529cd6e9054166af7762bc9faad0 to your computer and use it in GitHub Desktop.
'composer install' git post-checkout hook
# .git/hooks/post-checkout
changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)"
composer_install_on_changed_lockfile() {
echo "$changed_files" | grep --quiet "composer.lock" &&
echo "Changes to 'composer.lock' detected; running 'composer install'." &&
composer install
}
composer_install_on_changed_lockfile
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment