forked from theSteveMitchell/.heartfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge.sh
executable file
·78 lines (66 loc) · 2.29 KB
/
merge.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
74
75
#script used for promoting code through a 3-branch heirarchy (master => qa => staging)
#step 1: reverse-merge all changes from staging => qa => master. Push up to remote
#step 2: merge master => qa OR qa => staging. Depends on parameter you pass in.
#step 3: run specs. Push up to remote if specs pass. Don't push if specs don't pass.
#if you have a project that is not using this 3-branch model, then go use git-flow and leave me alone.
source ~/.bash_profile
if [ $# -lt 1 ]; then
echo "I understand you want me to merge something, but you have to tell me where (qa or staging)"
exit
fi
git checkout master
git pull origin master
git checkout staging
git pull origin staging
git checkout qa
git pull origin qa
git merge staging
git push origin qa
git checkout master
git pull origin master
git merge qa
git push origin master
if [ $1 == 'staging' ]; then
echo "merging to qa to staging."
git checkout staging
git merge qa
SUCESS_OUTPUT="\, 0 failures"
bundle
bundle exec rake db:migrate && bundle exec rake db:test:prepare && git checkout db/schema.rb
echo "This script will run 'rake' command to make sure your test suite passes before pushing"
exec 5>&1
OUTPUT=$( bundle exec rspec spec | tee /dev/fd/5)
if echo "$OUTPUT" | grep -q "$SUCESS_OUTPUT"; then
echo 'Test passed! proceeding with the push'
git push origin staging
git checkout master
exit
else
echo "Some test did not pass! Failed test are shown above. Push aborted!"
git checkout master
exit 1
fi
elif [ $1 == 'qa' ]; then
git checkout qa
git merge master
SUCESS_OUTPUT="\, 0 failures"
bundle
bundle exec rake db:migrate && bundle exec rake db:test:prepare && git checkout db/schema.rb
echo "This script will run 'rake' command to make sure your test suite passes before pushing"
exec 5>&1
OUTPUT=$( bundle exec rspec spec | tee /dev/fd/5)
if echo "$OUTPUT" | grep -q "$SUCESS_OUTPUT"; then
echo 'Test passed! proceeding with the push'
git push origin qa
git checkout master
exit
else
echo "Some test did not pass! Failed test are shown above. Push aborted!"
git checkout master
exit 1
fi
else
echo "not gonna do it. Wouldn't be prudent."
exit
fi
fi