Skip to content

Instantly share code, notes, and snippets.

@freegenie
Created June 12, 2010 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freegenie/435708 to your computer and use it in GitHub Desktop.
Save freegenie/435708 to your computer and use it in GitHub Desktop.
# Git hook to switch config files made for a Rails app
# Looks for config file named like the branch.
#
# i.e.: database.mybranch.yml
#
# If the file is found, copies that to the actual config
# overwriting the previous one.
#
# The third parameter is 1 when we are switching branches
#
if [ $3 -eq 1 ]; then
cb=$(git branch | grep \* | cut -d " " -f 2)
ll=$(echo $(ls -1 $GIT_DIR/../deploy/config/*.$cb.yml))
if [ "$ll" != "" ] ; then
echo "Branch config files found, copying"
fi
for real_name in $ll ; do
renamed=$(echo $real_name | sed -e s/$cb\.//)
cp -v $real_name $renamed
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment