forked from mono/monodevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion-checks
More file actions
executable file
·193 lines (175 loc) · 4.54 KB
/
Copy pathversion-checks
File metadata and controls
executable file
·193 lines (175 loc) · 4.54 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash -e
cd `dirname $0`
top_srcdir=`pwd`
script_name=./`basename $0`
#
# Script to check versions of dependencies
# To check the version for all dependencies, just run the script with no arguments.
# To check the version for a specific dependency, run the script with "check <dependency>"
# To reset a dependency to the needed version, run the script with "reset <dependency>"
# It is also possible to pass "reset all" to reset all dependencies
#
# md-addins
DEP[0]=md-addins
DEP_NAME[0]=MDADDINS
DEP_PATH[0]=${top_srcdir}/../md-addins
DEP_MODULE[0]=git@github.com:xamarin/md-addins.git
DEP_NEEDED_VERSION[0]=ab7a684a2d1d700a5abee5a92b6c548d7ab45d0c
DEP_BRANCH_AND_REMOTE[0]="master origin/master"
# heap-shot
DEP[1]=heap-shot
DEP_NAME[1]=HEAPSHOT
DEP_PATH[1]=${top_srcdir}/../heap-shot
DEP_MODULE[1]=git://github.com/mono/heap-shot.git
DEP_NEEDED_VERSION[1]=d726360d50d3a294ce6bdfcb2a82f9593e61c78c
DEP_BRANCH_AND_REMOTE[1]="master origin/master"
# other dependencies
# DEP[2]=...
# ...
function fetch_variables
{
IGNORE_VERSION=`eval echo \\\$IGNORE_${DEP_NAME[$1]}_VERSION`
THE_PATH=${DEP_PATH[$1]}
NAME=${DEP[$1]}
CUSTOM_VERSION=`eval echo \\\$DEP_NEEDED_VERSION_${DEP_NAME[$1]}`
if [[ "x$CUSTOM_VERSION" == "x" ]]; then
NEEDED_VERSION=${DEP_NEEDED_VERSION[$1]}
else
NEEDED_VERSION=$CUSTOM_VERSION
fi
if test -d "$THE_PATH"; then
cd "$THE_PATH"
VERSION=`git log | head -1 | awk '{print $2}' 2>/dev/null`
BRANCH=`git rev-parse --abbrev-ref HEAD 2>/dev/null`
cd "$top_srcdir"
else
VERSION=
BRANCH=
fi
CUSTOM_BRANCH=`eval echo \\\$DEP_BRANCH_${DEP_NAME[$1]}`
if [[ "x$CUSTOM_BRANCH" == "x" ]]; then
BRANCH_AND_REMOTE=${DEP_BRANCH_AND_REMOTE[$1]}
NEEDED_BRANCH=`echo "$BRANCH_AND_REMOTE" | sed -e 's, .*,,'`
else
BRANCH_AND_REMOTE="$CUSTOM_BRANCH origin/$CUSTOM_BRANCH"
NEEDED_BRANCH=$CUSTOM_BRANCH
fi
MODULE=${DEP_MODULE[$1]}
}
function reset_version
{
fetch_variables $1
if test -d "$THE_PATH"; then
cd "$THE_PATH"
if [[ ! git show "$NEEDED_VERSION" >/dev/null 2>&1 || "x$NEEDED_VERSION" == "xHEAD"]]; then
echo "*** [$NAME] git fetch $NAME"
git fetch
fi
else
echo "*** [$NAME] git clone $MODULE"
cd "`dirname $THE_PATH`"
git clone $MODULE
fi
if [[ "x$NEEDED_VERSION" == "xHEAD" ]]; then
NEEDED_VERSION=origin/$NEEDED_BRANCH
fi
cd "$THE_PATH"
echo "*** [$NAME] git checkout $NEEDED_BRANCH"
git checkout $NEEDED_BRANCH || git checkout -b $BRANCH_AND_REMOTE
echo "*** [$NAME] git reset --hard $NEEDED_VERSION"
(git reset --hard $NEEDED_VERSION && git submodule update --init --recursive) || exit 1;
cd "$top_srcdir"
}
function check_version
{
fetch_variables $1
if [[ "x$IGNORE_VERSION" == "x" ]]; then
if test ! -d "$THE_PATH"; then
echo "Your $NAME checkout is missing, please run '$script_name --reset $NAME'"
FAILURE=1
else
if [[ "x$NEEDED_VERSION" == "xHEAD" ]]; then
NEEDED_VERSION=`cd $THE_PATH && git log -1 --format=format:%H origin/$NEEDED_BRANCH`
fi
if [[ "x$VERSION" != "x$NEEDED_VERSION" || "x$BRANCH" != "x$NEEDED_BRANCH" ]]; then
echo "Your $NAME version is out of date, please run '$script_name --reset $NAME'"
FAILURE=1
fi
fi
fi
}
function reset_all
{
I=0
while [[ "x${#DEP[@]}" != "x$I" ]]; do
reset_version $I
let I=$I+1
done
}
function check_all
{
I=0
while [[ "x${#DEP[@]}" != "x$I" ]]; do
check_version $I
let I=$I+1
done
}
function find_dep
{
I=0
DEP_IDX=
while [[ "x${#DEP[@]}" != "x$I" ]]; do
if [[ "x${DEP[$I]}" == "x" ]]; then
echo "There is no dependency named $1"
exit 1
elif [[ "x${DEP[$I]}" == "x$1" ]]; then
DEP_IDX=$I
break;
fi
let I=$I+1
done
if [[ "x$DEP_IDX" == "x" ]]; then
echo "There is no dependency named $1"
exit 1
fi
}
FAILURE=0
if [[ "x$1" == "x" ]]; then
check_all
elif [[ "x$1" == "x--check-all" ]]; then
check_all
elif [[ "x$1" == "x--check" && "x$2" == "xall" ]]; then
check_all
elif [[ "x$1" == "x--check" && "x$2" == "x" ]]; then
check_all
elif [[ "x$1" == "x--check" ]]; then
shift
while [[ "x$1" != "x" ]]; do
find_dep $1
check_version $DEP_IDX
shift
done
elif [[ "x$1" == "x--reset-all" ]]; then
reset_all
elif [[ "x$1" == "x--reset" && "x$2" == "xall" ]]; then
reset_all
elif [[ "x$1" == "x--reset" && "x$2" == "x" ]]; then
reset_all
elif [[ "x$1" == "x--reset" ]]; then
shift
while [[ "x$1" != "x" ]]; do
find_dep $1
reset_version $DEP_IDX
shift
done
else
echo Unknown arguments: $@
echo 'Expected --reset|--check <list of dependencies>'
exit 1
fi
if [[ "x$FAILURE" == "x1" ]]; then
echo "One or more modules needs update"
exit 1
else
echo "All dependent modules up to date"
fi