git clone [email protected]:2425c534b6b20703af2cc361b4a93fb9.git githooks
GIT_HOOK_DIR="${PWD}/githooks"
echo "export GIT_HOOK_DIR=${GIT_HOOK_DIR}" >> ~/.bashrc
echo "${GIT_HOOK_DIR}/post-merge" >> .git/hooks/post-merge
echo "${GIT_HOOK_DIR}/post-checkout" >> .git/hooks/post-checkout
-
-
Save uncreative/2425c534b6b20703af2cc361b4a93fb9 to your computer and use it in GitHub Desktop.
git hook to run a command after `git pull` and `git checkout` if a specified file was change for example, package.json or bower.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)" | |
check_run() { | |
echo "$changed_files" | grep --quiet "$1" && eval "$2" | |
} | |
post_checkout(){ | |
make_reqs | |
echo "${GIT_HOOK_DIR}/post-checkout" >> .git/hooks/post-checkout | |
} | |
check_run base-private.txt post_checkout | |
check_run base.txt post_checkout | |
check_run dev-private.txt post_checkout | |
check_run dev.txt post_checkout | |
exit 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" | |
check_run() { | |
echo "$changed_files" | grep --quiet "$1" && eval "$2" | |
} | |
post_merge(){ | |
make_reqs | |
echo "${GIT_HOOK_DIR}/post-merge" >> .git/hooks/post-merge | |
} | |
check_run base-private.txt post_merge | |
check_run base.txt post_merge | |
check_run dev-private.txt post_merge | |
check_run dev.txt post_merge | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment