# Create a tag before committing and then move the tag to the commit (yes, a bit of a hack!)
version=`git describe --tags`
version="$version                    "
# if the only change is in Version.h or version.dart, don't add the + to the version
changes=`git diff --name-only --cached | grep -v "Version.h" | grep -v "version.dart" | wc -l | xargs`
if [[ "$changes" == "0" ]]
then
  version="${version:0:16}"
else
  version="${version:0:15}+"
fi
echo "#define VERSION \"$version\"" > src/Version.h
echo "const String gitVersion = '$version';" > extras/device_client/lib/model/version.dart
git add src/Version.h extras/device_client/lib/model/version.dart
