mirror of
https://github.com/AdaCore/Certyflie.git
synced 2026-02-12 12:27:35 -08:00
Some people prefer to use git (easy possible by using git-hg) therefor make the version-scripts git-aware. To not change the view of the version string(s), the version when using git still looks the same as if mercury is used (and not like a standard git-version).
45 lines
956 B
Bash
45 lines
956 B
Bash
#!/usr/bin/env bash
|
|
|
|
FILE=utils/src/version.c
|
|
|
|
MODIFIED=0
|
|
|
|
#Get the relevant informations
|
|
if test -d .git ; then
|
|
# git
|
|
ID=$(git describe --tags --abbrev=12 HEAD)
|
|
REV=${ID##*-}
|
|
REV=${REV:1}
|
|
LOCAL=${ID#*-*-}
|
|
TAG=${ID%-$LOCAL}
|
|
LOCAL=${LOCAL%-*}
|
|
git update-index -q --refresh
|
|
if ! test -z "$(git diff-index --name-only HEAD --)" ; then
|
|
MODIFIED=1
|
|
fi
|
|
else
|
|
# mercury
|
|
ID=$(hg identify -nit)
|
|
|
|
REV=$(echo -n $ID | cut -d' ' -f1)
|
|
LOCAL=$(echo -n $ID | cut -d' ' -f2)
|
|
TAG=$(echo -n $ID | cut -d' ' -f3)
|
|
|
|
#LOCAL=$(hg identify -n)
|
|
#REV=$(hg identify -i)
|
|
#TAG=$(hg identify -t)
|
|
#BRANCH=$(hg identify -b)
|
|
|
|
if echo -n $REV | grep +\$>/dev/null; then
|
|
MODIFIED=1
|
|
fi
|
|
fi
|
|
|
|
#Patch version.c
|
|
sed -i "s/SLOCAL_REVISION=\".*\";\$/SLOCAL_REVISION=\"$LOCAL\";/" $FILE
|
|
sed -i "s/STAG=\".*\";\$/STAG=\"$TAG\";/" $FILE
|
|
sed -i "s/SREVISION=\".*\";\$/SREVISION=\"$REV\";/" $FILE
|
|
sed -i "s/MODIFIED=.*;\$/MODIFIED=$MODIFIED;/" $FILE
|
|
|
|
true
|