Skip to content

Instantly share code, notes, and snippets.

@yalab
Created January 14, 2018 05:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yalab/b60891f9ed2029f7bc62197a5538882a to your computer and use it in GitHub Desktop.
Save yalab/b60891f9ed2029f7bc62197a5538882a to your computer and use it in GitHub Desktop.
ブランチを切り替えて Gemfile.lock や yarn.lock に変更があったら勝手に install する git hook
#!/bin/bash
PREV=$1
POST=$2
TRUE="1"
FALSE="0"
isChanged (){
FILE_CHANGED="$(git log $PREV..$POST --pretty='format:' --name-only | grep $1)"
if [ -n "$FILE_CHANGED" ];then
echo $TRUE
else
echo $FALSE
fi
}
if [ $(isChanged 'Gemfile.lock') = $TRUE ];then
bundle install
fi
if [ $(isChanged "yarn.lock") = $TRUE ];then
yarn install
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment