From: svnhieber Date: Tue, 18 Jan 2011 18:19:01 +0000 (+0000) Subject: svnrevision.sh now better; first looks for svn info, then git-svn, then gives up... X-Git-Url: https://git.rohieb.name/bachelor-thesis/roomba_tests.git/commitdiff_plain/d4fa43e14924805250c6e07edd401f45953d3c84 svnrevision.sh now better; first looks for svn info, then git-svn, then gives up, but writes a SVNREVISION define in any case git-svn-id: https://svn.itm.uni-luebeck.de/wisebed/wiselib/trunk/pc_apps/roomba_tests@4090 f8795833-4959-0410-8ae9-8bcb0cfab428 --- diff --git a/svnrevision.sh b/svnrevision.sh index 072d714..c90f410 100755 --- a/svnrevision.sh +++ b/svnrevision.sh @@ -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