From 848aa4472f2d80a4833a2e3051f50de9db8380e6 Mon Sep 17 00:00:00 2001 From: michi_cc Date: Fri, 2 Jul 2010 16:34:15 +0000 Subject: (svn r20050) -Add: git revision detection for custom git-svn clones. --- findversion.sh | 8 ++++++-- projects/determineversion.vbs | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/findversion.sh b/findversion.sh index f636844dd..5e4e6f442 100755 --- a/findversion.sh +++ b/findversion.sh @@ -94,8 +94,12 @@ elif [ -d "$ROOT_DIR/.git" ]; then fi HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null` REV="g`echo $HASH | cut -c1-8`" - BRANCH=`git branch|grep '[*]' | sed 's@\* @@;s@^master$@@'` - REV_NR=`LC_ALL=C git log --pretty=format:%s "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"` + BRANCH=`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@;s@^master$@@'` + REV_NR=`LC_ALL=C git log --pretty=format:%s --grep="^(svn r[0-9]*)" -1 -- "$SRC_DIR" | sed "s@.*(svn r\([0-9]*\)).*@\1@"` + if [ -z "$REV_NR" ]; then + # No rev? Maybe it is a custom git-svn clone + REV_NR=`LC_ALL=C git log --pretty=format:%b --grep="git-svn-id:.*@[0-9]*" -1 -- "$SRC_DIR" | sed "s@.*\@\([0-9]*\).*@\1@"` + fi elif [ -d "$ROOT_DIR/.hg" ]; then # We are a hg checkout if [ -n "`hg status \"$SRC_DIR\" | grep -v '^?'`" ]; then diff --git a/projects/determineversion.vbs b/projects/determineversion.vbs index 9d9f21f6e..338b3d2b0 100755 --- a/projects/determineversion.vbs +++ b/projects/determineversion.vbs @@ -203,6 +203,17 @@ Function DetermineSVNVersion() revision = Mid(oExec.StdOut.ReadLine(), 7) revision = Mid(revision, 1, InStr(revision, ")") - 1) End If ' Err.Number = 0 + If revision = "" Then + ' No revision? Maybe it is a custom git-svn clone + ' Reset error number as WshShell.Exec will not do that on success + Err.Clear + Set oExec = WshShell.Exec("git log --pretty=format:%b --grep=" & Chr(34) & "git-svn-id:.*@[0-9]*" & Chr(34) & " -1 ../src") + If Err.Number = 0 Then + revision = oExec.StdOut.ReadLine() + revision = Mid(revision, InStr(revision, "@") + 1) + revision = Mid(revision, 1, InStr(revision, " ") - 1) + End If ' Err.Number = 0 + End If ' revision = "" End If ' Err.Number = 0 End If ' oExec.ExitCode = 0 End If ' Err.Number = 0 -- cgit v1.2.3-70-g09d2