From f23af6b99679ddf2add5d71944b9c7f825ac2514 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Thu, 19 Jul 2012 09:24:14 +0200 Subject: [PATCH] Check the working directory before preparing the archive The script test for the usual things I always forget: 1) Update the po files. 2) Commit the changes. 3) Set a git tag to find the version back. --- archive.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/archive.sh b/archive.sh index 61fb6b2..dc3621f 100755 --- a/archive.sh +++ b/archive.sh @@ -3,6 +3,7 @@ Sources="." Target=".." +# check version number in every file Version=$(cat "$Sources/CMakeLists.txt" | sed -n -e 's/^SET(sarg_VERSION \([0-9]\))/\1/p') if [ -z "$Version" ] ; then echo "No version found" @@ -21,6 +22,47 @@ if [ "x$Version" != "x$VersionCheck" ] ; then exit 1 fi +# update the po files +if ( ! make update-po ) ; then + echo "Failed to update the po files" + exit 1 +fi + +# is the git repository dirty? +if [[ $(git diff --shortstat 2> /dev/null) != "" ]] ; then + echo "Git repository is dirty" + exit 1 +fi + +# check the working tree +if ( ! git diff-files --quiet ) ; then + echo "Uncommitted changes in working tree" + exit 1 +fi + +# check the index for uncommitted changes +if ( ! git diff-index --quiet --cached HEAD ) ; then + echo "Uncommitted changes in the index" + exit 1 +fi + +# check for untracked files +Untracked="$(git ls-files --exclude-standard --others)" +if [[ -n "$Untracked" ]] ; then + echo "Untracked files in directory" + echo "$Untracked" + exit 1 +fi + +# is the git tag set? +GitVersion=$(git describe) +if [[ "$GitVersion" != "$Version" ]] ; then + echo "Git tag not set for version $Version. Use command:" + echo "git tag -a \"$Version\" -m \"$Version\"" + exit 1 +fi + +# prepare the archive SargList="$Target/sarglist.txt.unsort" SortList="$Target/sarglist.txt" DirList="$Target/sargdir.txt" -- 2.47.3