forked from infinitest/infinitest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.sh
executable file
·53 lines (43 loc) · 1.18 KB
/
push.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
#!/bin/bash
function alert_user {
echo "${1}"
which -s growlnotify && growlnotify `basename $0` -m "${1}"
}
function exit_ko {
alert_user "${1}"; exit 1
}
function exit_ok {
alert_user "${1}"; exit 0
}
LOCATION=$(pwd)
REMOTE=${1:-origin}
REMOTE_URL=$(git remote show -n ${REMOTE} | awk '/Fetch/ {print $3}')
BRANCH=$(git symbolic-ref -q HEAD)
BRANCH=${BRANCH##refs/heads/}
# Git black magic to pull rebase even with uncommited work in progress
git fetch ${REMOTE}
git add -A; git ls-files --deleted -z | xargs -0 -I {} git rm {}; git commit -m "wip"
git rebase ${REMOTE}/${BRANCH}
if [ "$?" -ne 0 ]; then
git rebase --abort
git log -n 1 | grep -q -c "wip" && git reset HEAD~1
exit_ko "Unable to rebase. please pull or rebase and fix conflicts manually."
fi
git log -n 1 | grep -q -c "wip" && git reset HEAD~1
# Private build
rm -Rf ../privatebuild
git clone -slb "${BRANCH}" . ../privatebuild
cd ../privatebuild
# Build with maven
mvn install
if [ $? -ne 0 ]; then
exit_ko "Unable to build"
fi
# Push
git push ${REMOTE_URL} ${BRANCH}
if [ $? -ne 0 ]; then
exit_ko "Unable to push"
fi
# Update working directory
cd ${LOCATION} && git fetch ${REMOTE}
exit_ok "Yet another successful build!"