-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.sh
73 lines (54 loc) · 1.29 KB
/
checkout.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
if [ -z $1 ]; then
echo "Usage: checkout branch-name [-f]"
echo "Options:"
echo " -f Perform a git-fetch before checkout branch-name"
return
fi
if [ -z "$DEV_ROOT_PATH" ]; then
echo "Error: DEV_ROOT_PATH env var is not set"
return
fi
PREFIX="\033[1m\033[34m"
SUFFIX="\033[39m\033[0m"
function log {
echo -e "$PREFIX+ $1$SUFFIX"
}
cd $DEV_ROOT_PATH
if [ "$2" = "-f" ]; then
log "git fetch"
git fetch
fi
if [ "$(git status -s)" = " M db/structure.sql" ]; then
log "git checkout db/structure.sql"
git checkout db/structure.sql
fi
log "git status"
git status
if [ -n "$(git status -s)" ]; then
read -p "These files will be wiped. Continue? > (yN)" choice
if [ "$choice" != "y" ]; then
log "Chose no. Do nothing."
return
fi
log "git add ."
git add .
log "git commit -nm 'wip'"
git commit -nm 'wip'
fi
log "git checkout $1"
git checkout $1
log "git pull --rebase"
git pull --rebase
if [ "$(git log -n 1 --pretty=format:%s)" = "wip" ]
then
log "git reset HEAD~1"
git reset HEAD~1
fi
log "git status"
git status
log "bundle install > /tmp/bundle-install.log"
bundle install > /tmp/bundle-install.log
log "bundle exec rake db:migrate"
bundle exec rake db:migrate
log "RAILS_ENV=test bundle exec rake db:migrate"
RAILS_ENV=test bundle exec rake db:migrate