-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcheckout.sh
executable file
·155 lines (139 loc) · 2.99 KB
/
checkout.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/sh
usage()
{
cat << EOF
usage: $0 options
This script will check out Seam 3.
OPTIONS:
-a When performing a fetch use --all to retrieve all remotes
-b Build and install parent, tools and bom modules
-h Show this usage message
-d Destination directory, otherwise the PWD is used
-m Checkout (clone) in manager mode (SSH mode) (default is read-only)
-v Be more verbose
-c Don't run git fetch if the repository has already been cloned
-p Perform a git pull origin for each of the modules
EOF
}
work()
{
if [ "$READONLY" -eq "1" ]
then
GITBASE="git://github.com/seam"
else
GITBASE="[email protected]:seam"
fi
if [ "$VERBOSE" -eq "0" ]
then
GITARGS=""
fi
if [ -d $DESTINATION ]
then
echo "Using existing destination directory $DESTINATION"
else
echo "Creating destination directory $DESTINATION"
mkdir $DESTINATION
fi
for repo in $REPOS
do
update=0
unset gitcmd
url="$GITBASE/$repo.git"
repodir=$DESTINATION/$repo
if [ -d $repodir ]
then
if [ "$GITFETCH" -eq "1" ]; then
echo "Updating $repo"
if [ "$FETCHALL" -eq "1" ]; then
gitcmd="git $GITARGS --git-dir=$DESTINATION/$repo/.git fetch --all"
else
gitcmd="git $GITARGS --git-dir=$DESTINATION/$repo/.git fetch"
fi
update=1
$gitcmd
else
echo "Skipping existing cloned repository $DESTINATION/$repo"
update=1
fi
fi
if [ "$PULL" -eq "1" ]; then
cd $DESTINATION/$repo
status=$(git status --porcelain)
if [ -z "$status" ]; then
echo "Pulling $repo"
gitcmd="git $GITARGS pull"
$gitcmd
update=1
else
echo "Local changes, no pull occurred"
fi
fi
if [ "$update" -eq "0" ]; then
echo "Cloning $repo"
gitcmd="git clone $GITARGS $url $DESTINATION/$repo"
$gitcmd
fi
done
if [ "$BUILD" -eq "1" ]
then
echo "Building Seam parent, tools and bom modules"
cd build/parent
mvn clean install
cd -
cd build/tools
mvn clean install
cd -
cd dist
mvn clean install -N
cd -
fi
}
DESTINATION=`pwd`
READONLY=1
VERBOSE=0
GITBASE=
GITARGS=
GITFETCH=1
FETCHALL=0
BUILD=0
PULL=0
RUN=1
REPOS="parent build dist examples catch config drools faces international jcr jms mail persistence remoting rest security servlet social solder validation ticket-monster wicket"
while getopts “aphmd:bcv” OPTION
do
case $OPTION in
a)
FETCHALL=1
;;
h)
usage
RUN=0
;;
d)
DESTINATION=$OPTARG
;;
c)
GITFETCH=0
;;
m)
READONLY=0
;;
b)
BUILD=1
;;
v)
VERBOSE=1
;;
p)
PULL=1
;;
[?])
usage;
RUN=0
;;
esac
done
if [ "$RUN" -eq "1" ]
then
work;
fi