-
Notifications
You must be signed in to change notification settings - Fork 25
/
.update-changes.cfg
35 lines (29 loc) · 1023 Bytes
/
.update-changes.cfg
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
# Automatically adapt version in files.
function replace_broker_version_hh
{
version=$1
file=libbroker/broker/version.hh
major=$(echo $version | cut -d'.' -f1)
minor=$(echo $version | cut -d'.' -f2)
patch_suffix=$(echo $version | cut -d'.' -f3)
patch=$(echo $patch_suffix | cut -d'-' -f1)
echo $version | grep -q "-"
if [ $? -eq 0 ]; then
suffix=-$(echo $patch_suffix | cut -d'-' -f2)
else
suffix=""
fi
cat $file | sed \
-e "s#\([[:space:]]*constexpr type major[[:space:]]*=[[:space:]]*\)[0-9]*;#\1$major;#g" \
-e "s#\([[:space:]]*constexpr type minor[[:space:]]*=[[:space:]]*\)[0-9]*;#\1$minor;#g" \
-e "s#\([[:space:]]*constexpr type patch[[:space:]]*=[[:space:]]*\)[0-9]*;#\1$patch;#g" \
-e "s#\([[:space:]]*constexpr auto suffix[[:space:]]*=[[:space:]]*\)\".*\";#\1\"$suffix\";#g" \
>$file.tmp
mv $file.tmp $file
git add $file
}
function new_version_hook
{
version=$1
replace_broker_version_hh $version
}