svnrevision.sh now better; first looks for svn info, then git-svn, then gives up...
[bachelor-thesis/roomba_tests.git] / svnrevision.sh
index 072d714..c90f410 100755 (executable)
@@ -1,19 +1,24 @@
 #!/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
This page took 0.024803 seconds and 4 git commands to generate.