-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreateTemplate.sh
137 lines (95 loc) · 2.59 KB
/
createTemplate.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# !/bin/bash
######################
# bash createTemplate.sh PROJECT_TYPE -bb branchName
# $1 - project type
# $2 - key for adding of basic branches or not
# $3 - basic (start) branch
######################
### variables
#
DIR=$(pwd)
#
### branches
PROJECT_BRANCHES="dev,feature,fix,adhoc,integration,release,held,controlTest"
ADHOC_BRANCHES="dev,adhoc,integration,release,held,controlTest"
REMOTE="origin"
PROJECT_TYPE=$1
if [ $3 ]; then
START_BRANCH=$3
else
START_BRANCH='master'
fi
######################
# copy all files
shopt -s dotglob
if [ $1 == "project" ]; then
echo "Adding project template..."
$(cp -r $DIR/templates/project/* $DIR)
# add --bare | cloning abilities
$(git init)
if [ $2=="-bb" ]; then
echo "Adding project template with basic branch structure..."
WITHBR=True
for BRANCH in $(echo $PROJECT_BRANCHES | sed -n 1'p' | tr ',' '\n')
do
git branch $BRANCH
done
else
echo "Adding project template without branches..."
WITHBR=False
fi
elif [ $1 == "adhoc" ]; then
echo "Adding Ad-Hoc template..."
$(cp -r $DIR/template/adHoc/* $DIR)
# add --bare | cloning abilities
$(git init)
if [ $2=="-bb" ]; then
echo "Adding project template with basic branch structure..."
WITHBR=True
for BRANCH in $(echo $ADHOC_BRANCHES | sed -n 1'p' | tr ',' '\n')
do
git branch $BRANCH
done
else
echo "Adding project template without branches..."
WITHBR=False
fi
elif [ $1 == "query" ]; then
echo "Adding Query Lib template..."
$(cp -r $DIR/template/queryLib/* $DIR)
# add --bare | cloning abilities
$(git init)
if [ $2=="-bb" ]; then
echo "Adding project template with basic branch structure..."
WITHBR=True
for BRANCH in $(echo $PROJECT_BRANCHES | sed -n 1'p' | tr ',' '\n')
do
git branch $BRANCH
done
else
echo "Adding project template without branches..."
WITHBR=False
fi
else
echo "You didn't set up a right type of project"
exit 0
fi
if [ START_BRANCH ] ; then
echo "Switching to existing branch..."
git checkout $START_BRANCH
TRACKING=$(git branch -vv | grep "*" | awk '{ print $4 '})
git branch --set-upstream-to $START_BRANCH
git checkout -b $START_BRANCH --track $START_BRANCH
fi
echo 'Dropping to basic templates'
rm -r $DIR/template
echo 'Adding files to gitignore'
echo 'createTemplate.sh' >> .gitignore
echo 'createSSHKey.sh' >> .gitignore
echo 'changeAddOrigin.sh' >> .gitignore
echo 'mergeTo.sh' >> .gitignore
echo 'pull.sh' >> .gitignore
echo 'push.sh' >> .gitignore
echo 'addBranch.sh' >> .gitignore
echo 'combine2repo.sh' >> .gitignore
echo 'createSSHKey.sh' >> .gitignore