-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnewbranch
executable file
·66 lines (51 loc) · 1.65 KB
/
newbranch
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
#!/bin/bash
############################################################
## YOUR VALUES ##
#################
## Specify the version of 'master' if anything other than
## 'upcoming'. To disable this checking, change this value
## to 'master' instead:
CURRENTMASTER="v5.0"
############################################################
## BEGIN SCRIPT ##
##################
SOURCEISMASTER=0
TMPDIR=/tmp/newbranch$$
## Check for provided parameter:
PARAMETER=$1
## Parse user-provided parameter and determine what to do:
if [[ -z $PARAMETER || ! -z $2 ]]; then
echo -e "\nERROR: Either no or 2+ parameters provided. You must provide ONE"
echo -e " MDB version like: v4.2.3, v4.0.14, etc"
echo -e " Exiting ...\n"
exit;
elif [ `echo $PARAMETER | sed 's%^v%%g' | egrep -c '^[0-9]\.[0-9]\.[0-9]{1,2}$'` -lt 1 ]; then
echo -e "\nERROR: Invalid MDB version provided."
echo -e " Must be ONE MDB version like: v4.2.3, v4.0.14, etc"
echo -e " Exiting ...\n"
exit;
else
VERS=`echo $PARAMETER | sed 's%^v%%g'`
MAJORVERS=`echo $VERS | awk -F'.' '{print $1"."$2}'`
## Determine if provided VERS requires 'master' as source branch:
CURRENTMASTER=`echo $CURRENTMASTER | sed 's%^v%%g'`
if [ $CURRENTMASTER == $MAJORVERS ]; then
SOURCEISMASTER=1
fi
fi
mkdir -p $TMPDIR
cd $TMPDIR
git clone [email protected]:mongodb/docs.git
cd docs
## Source new minor release branch from appropriate
## major release branch:
if [ $SOURCEISMASTER == 1 ]; then
git checkout master
git pull --rebase
git push origin master:v$VERS
else
git checkout v$MAJORVERS
git pull --rebase
git push origin v$MAJORVERS:v$VERS
fi
rm -rf $TMPDIR