36 lines
1023 B
INI
36 lines
1023 B
INI
# 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
|
|
}
|