-
Notifications
You must be signed in to change notification settings - Fork 2
/
post-receive
executable file
·60 lines (42 loc) · 1.42 KB
/
post-receive
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
#!/bin/sh
#
# An example hook script for the "post-receive" event.
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated. It is passed arguments in through
# stdin in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
#
# see contrib/hooks/ for a sample, or uncomment the next line and
# rename the file to "post-receive".
#. /usr/share/git-core/contrib/hooks/post-receive-email
echo "-------- Running custom post-receive hook"
sha=`git log -1 HEAD | head -1 | awk '{print $2;}'`
message=`git log -1 HEAD | tail -1`
USER="bdecoste"
OPENSHIFT_GIT="ssh://[email protected]/~/git/demo.git/"
SOURCE_GIT="/mnt/extra/git/project.git"
KEY="[OPENSHIFT]"
echo "${sha}"
echo "${message}"
if [[ ${message} == *${KEY}* ]]
then
echo "${KEY} found. Beginning Gear merge in post-receive hook"
git clone ${OPENSHIFT_GIT} /mnt/extra/tmp/${sha}
pushd /mnt/extra/tmp/${sha}
unset GIT_DIR
unset GIT_WORK_TREE
git remote add upstream ${SOURCE_GIT}
git fetch upstream
git checkout -b upstream upstream/master
git config --global user.name "${USER}"
git checkout master
git merge upstream -m "test" -X theirs
git push
popd
else
echo "${KEY} not found. No additional processing in post-receive hook"
fi
#rm -rf /mnt/extra/tmp/${sha}