Wrap text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
BRANCH=`git symbolic-ref HEAD 2> /dev/null | sed -e 's/^.*\///'`
GITPATH="`git rev-parse --git-dir 2>/dev/null`/.."
if [ "$BRANCH" == "" ]; then
echo "no branch name. do nothing"
exit 0
fi
if [ -f "$GITPATH/config/database.yml" ] && [ ! -L "$GITPATH/config/database.yml" ]; then
echo "database.yml exists and not a symlink. do nothing."
exit 0
fi
echo "look for $GITPATH/config/database.$BRANCH.yml"
if [ -f "$GITPATH/config/database.$BRANCH.yml" ]; then
echo "switch database configuration file to config/database.$BRANCH.yml"
rm -f "$GITPATH/config/database.yml";
ln -s "$GITPATH/config/database.$BRANCH.yml" \
"$GITPATH/config/database.yml"
fi
|