-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_modules_version.sh
More file actions
executable file
·52 lines (44 loc) · 1.58 KB
/
Copy pathchange_modules_version.sh
File metadata and controls
executable file
·52 lines (44 loc) · 1.58 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
#!/bin/bash
echo "Checkouting all the modules to version "$1
target_version=$1
# Validate version
version_re_pattern=[0-9]\.[0-9]
if [[ ! $target_version =~ $version_re_pattern ]]; then
echo "Error: Version should be like 3.8, i.e. two digits separated by a dot."
return
fi
# Go to the modules directory
cd ../trytond/trytond/modules/
# Loop through all the modules
for m in $( ls -d */ ); do
echo ${m:: -1}
cd $m
# Check if we are already on the desired branch/version
if [[ ! `git rev-parse --abbrev-ref HEAD` = $target_version ]]; then
# Checkout to the needed version
if [[ `git ls-remote --heads origin $target_version` ]]; then
git checkout $target_version >/dev/null 2>&1
else
echo " Warning: Exact version match was not found, looking for some previous minor release. Stable working is not guaranteed."
found=0
for v in `seq ${target_version: -1} -1 0`; do
version=${target_version:: -1}$v
if [[ `git ls-remote --heads origin $version` ]]; then
# Checkout and suppress any messages
git checkout $version >/dev/null 2>&1
found=1
break
fi
done
if [[ $found = 0 ]]; then
echo " Error: No suitable version was found! Deleting this module."
cd ..
rm -rf $m
continue
fi
fi
fi
echo " `git rev-parse --abbrev-ref HEAD`"
cd ..
done
cd ../../../trytond-scripts/