]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Check the working directory before preparing the archive
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 19 Jul 2012 07:24:14 +0000 (09:24 +0200)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 19 Jul 2012 07:24:14 +0000 (09:24 +0200)
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

index 61fb6b271117d6cda8bcf8abe2885c752f69fd66..dc3621fe935ace23a878e95ff0b0989ff1f440ce 100755 (executable)
@@ -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"