diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/get-scala-revision | 31 | ||||
-rw-r--r-- | tools/get-scala-revision.bat | 28 |
2 files changed, 14 insertions, 45 deletions
diff --git a/tools/get-scala-revision b/tools/get-scala-revision index 8731705d06..e8597844cc 100755 --- a/tools/get-scala-revision +++ b/tools/get-scala-revision @@ -1,30 +1,19 @@ #!/bin/sh # # Usage: get-scala-revision [dir] -# Figures out current scala revision of an svn checkout or -# a git-svn mirror (or a git clone.) +# Figures out current scala revision of a git clone. # # If no dir is given, current working dir is used. -DIR="" -if [ $# -eq 0 ]; then - DIR=`pwd` -else - DIR=$1 -fi - -cd $DIR +[ -n "$1" ] && cd "$1" -if [ -d .svn ]; then - # 2>&1 to catch also error output (e.g. svn warnings) - svn info . 2>&1 | grep ^Revision | sed 's/Revision: //' -elif [ -d .git ]; then - GIT_PAGER=cat - # this grabs more than one line because otherwise if you have local - # commits which aren't in git-svn it won't see any revision. - git log -10 | grep git-svn-id | head -1 | sed 's/[^@]*@\([0-9]*\).*/\1/' +# dev should be a tag at the merge-base of master and the +# most recent release. +if [ -z $(git tag -l dev) ]; then + # no dev tag available - this will generate dev-g<sha> + echo "dev-g$(git describe HEAD --abbrev=7 --always)" else - echo "${DIR} doesn't appear to be git or svn dir." >&2 - echo 0 - exit 1 + # dev tag exists - this generates dev-NNNN-g<sha> + # where NNNN is the number of commits since dev. + git describe HEAD --abbrev=7 --match dev fi diff --git a/tools/get-scala-revision.bat b/tools/get-scala-revision.bat index 880bcc3f5c..f4dc24b71f 100644 --- a/tools/get-scala-revision.bat +++ b/tools/get-scala-revision.bat @@ -1,17 +1,11 @@ @echo off rem rem Usage: get-scala-revison.bat [dir] -rem Figures out current scala revision of an svn checkout or -rem a git-svn mirror (or a git clone.) +rem Figures out current scala revision of a git clone. rem rem If no dir is given, current working dir is used. -if "%OS%" NEQ "Windows_NT" ( - echo "Sorry, your version of Windows is too old to run Scala." - goto :eof -) @setlocal - set _DIR= if "%*"=="" ( for /f "delims=;" %%i in ('cd') do set "_DIR=%%i" @@ -20,23 +14,9 @@ if "%*"=="" ( ) cd %_DIR% -if exist .svn\NUL ( - rem 2>&1 to catch also error output (e.g. svn warnings) - for /f "skip=4 tokens=2" %%i in ('svn info') do ( - echo %%i - goto :end - ) -) else ( if exist .git\NUL ( - set _GIT_PAGER=type - rem this grabs more than one line because otherwise if you have local - rem commits which aren't in git-svn it won't see any revision. - rem TODO: git log -10 | findstr git-svn-id | ... - echo 0 -) else ( - echo %_DIR% doesn't appear to be git or svn dir. - echo 0 - exit 1 -)) +if exist .git\NUL ( + git describe HEAD --abbrev=7 --match dev +) :end @endlocal |