#!/bin/bash
-if [ -d .svn ]; then
- revision=$(svn info|grep Revision|sed 's/Revision: //')
- stat=$(svn status|grep '^M')
-elif [ -d .git/svn ]; then
- revision=$(git svn info|grep Revision|sed 's/Revision: //')
- stat=$(git status|grep 'modified: ')
-else
- echo No SVN working copy!
- exit 1;
+
+# try SVN
+revision=$(svn info 2>&1|grep Revision|sed 's/Revision: //')
+stat=$(svn status 2>&1|grep '^M')
+
+# if that fails, try git-svn
+if [ -z "$revision" ]; then
+ revision=$(git svn info 2>&1|grep Revision|sed 's/Revision: //')
+ stat=$(git status 2>&1|grep 'modified: ');
fi;
-if [ -n "$stat" ]; then
- status=" with local changes"
+# if that fails, give up
+if [ -z "$revision" ]; then
+ $revision="No SVN or git-svn working copy!"
else
- status=""
+ if [ -n "$stat" ]; then
+ status=" with local changes"
+ else
+ status=""
+ fi;
fi;
echo '// This file is created automatically, your changes will be lost.' > svnrevision.h