Skip to content

Instantly share code, notes, and snippets.

@r4v
Created July 27, 2017 18:51
Show Gist options
  • Save r4v/f81225e73ea135077c7418dbff1e4960 to your computer and use it in GitHub Desktop.
Save r4v/f81225e73ea135077c7418dbff1e4960 to your computer and use it in GitHub Desktop.
laravel post-merge hook
#!/usr/bin/env bash
# git hook to run some silly stuff after `git pull` AND 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"
}
# Example usage
check_run package.json "npm install && npm run dev"
check_run composer.json "composer --dev install"
check_run test "phpunit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment