-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpullto
78 lines (67 loc) · 1.9 KB
/
pullto
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
76
77
78
#!/bin/bash
HERE=$(dirname ${BASH_SOURCE[0]})
. ${HERE}/fixpath
if ! checkDANKEY ; then
exit 1
fi
if ! allcommitted ; then
>&2 echo "Local status is not safe enough to run this command."
exit 1
fi
if [ "$#" -lt 1 ] ; then
echo Usage: $0 targetbranch
exit 1
fi
target=$1
currentbranch=$(branch)
if ! branchexists "$target" ; then
if branchexists -r origin/$target ; then
git checkout -b $target origin/$target
git checkout $currentbranch
fi
fi
if ! branchexists $target ; then
>&2 echo no branch found: $target
exit 1
fi
if git merge-base $(branch) --is-ancestor $target ; then
echo This branch has already been merged to $target
exit 1
fi
aborted=notaborted
career=nocareer
if [ $aborted != aborted ] ; then
echo Testing the pull request will not be blocked by conflicts ...
# Generate a safe branch off the target and merge into it
preparebranchforpullrequest.sh $target | tee /tmp/preparebranchforpullrequest$$
if [ "${PIPESTATUS[0]}" = "1" ] ; then
aborted=aborted
else
if grep "^USER REQUESTED: DON'T ASK ANYMORE" /tmp/preparebranchforpullrequest$$ > /dev/null 2>&1 ; then
career=career
fi
fi
fi
\rm /tmp/preparebranchforpullrequest$$
if [ $aborted != aborted ] ; then
# create a pull request on bitbucket from that safe branch to the target
if [ $career = career ] ; then
if ! ( yes | createpullrequest $target ) ; then
aborted=aborted
fi
elif ! createpullrequest $target ; then
aborted=aborted
fi
fi
if [ $aborted != aborted ] ; then
# merge that pull request no-ff
if [ $career = career ] ; then
if ! ( yes | mergepullrequest $target --strategyId=no-ff ) ; then
aborted=aborted
fi
elif ! mergepullrequest $target --strategyId=no-ff ; then
aborted=aborted
fi
fi
# delete staging branches
runCleanup.sh