diff --git a/findversion.sh b/findversion.sh --- a/findversion.sh +++ b/findversion.sh @@ -66,20 +66,19 @@ fi # Find out some dirs cd `dirname "$0"` ROOT_DIR=`pwd` -SRC_DIR=src # Determine if we are using a modified version # Assume the dir is not modified MODIFIED="0" if [ -d "$ROOT_DIR/.svn" ]; then # We are an svn checkout - if [ -n "`svnversion \"$SRC_DIR\" | grep 'M'`" ]; then + if [ -n "`svnversion | grep 'M'`" ]; then MODIFIED="2" fi # Find the revision like: rXXXXM-branch - BRANCH=`LC_ALL=C svn info "$SRC_DIR" | "$AWK" '/^URL:.*branches/ { split($2, a, "/"); for(i in a) if (a[i]=="branches") { print a[i+1]; break } }'` - TAG=`LC_ALL=C svn info "$SRC_DIR" | "$AWK" '/^URL:.*tags/ { split($2, a, "/"); for(i in a) if (a[i]=="tags") { print a[i+1]; break } }'` - REV_NR=`LC_ALL=C svn info "$SRC_DIR" | "$AWK" '/^Last Changed Rev:/ { print $4 }'` + BRANCH=`LC_ALL=C svn info | "$AWK" '/^URL:.*branches/ { split($2, a, "/"); for(i in a) if (a[i]=="branches") { print a[i+1]; break } }'` + TAG=`LC_ALL=C svn info | "$AWK" '/^URL:.*tags/ { split($2, a, "/"); for(i in a) if (a[i]=="tags") { print a[i+1]; break } }'` + REV_NR=`LC_ALL=C svn info | "$AWK" '/^Last Changed Rev:/ { print $4 }'` if [ -n "$TAG" ]; then REV=$TAG else @@ -89,26 +88,26 @@ elif [ -d "$ROOT_DIR/.git" ]; then # We are a git checkout # Refresh the index to make sure file stat info is in sync, then look for modifications git update-index --refresh >/dev/null - if [ -n "`git diff-index HEAD \"$SRC_DIR\"`" ]; then + if [ -n "`git diff-index HEAD`" ]; then MODIFIED="2" fi HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null` REV="g`echo $HASH | cut -c1-8`" 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@"` + REV_NR=`LC_ALL=C git log --pretty=format:%s --grep="^(svn r[0-9]*)" -1 | 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@"` + REV_NR=`LC_ALL=C git log --pretty=format:%b --grep="git-svn-id:.*@[0-9]*" -1 | 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 + if [ -n "`hg status | grep -v '^?'`" ]; then MODIFIED="2" fi HASH=`LC_ALL=C hg id -i | cut -c1-12` REV="h`echo $HASH | cut -c1-8`" BRANCH=`hg branch | sed 's@^default$@@'` - REV_NR=`LC_ALL=C hg log -r $HASH:0 -k "svn" -l 1 --template "{desc}\n" "$SRC_DIR" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"` + REV_NR=`LC_ALL=C hg log -r $HASH:0 -k "svn" -l 1 --template "{desc}\n" | grep "^(svn r[0-9]*)" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"` else # We don't know MODIFIED="1" diff --git a/projects/determineversion.vbs b/projects/determineversion.vbs --- a/projects/determineversion.vbs +++ b/projects/determineversion.vbs @@ -105,7 +105,7 @@ Function DetermineSVNVersion() If sTortoise <> "" Then Dim SubWCRev Set SubWCRev = WScript.CreateObject("SubWCRev.object") - SubWCRev.GetWCInfo FSO.GetAbsolutePathName("../src"), 0, 0 + SubWCRev.GetWCInfo FSO.GetAbsolutePathName("../"), 0, 0 revision = SubWCRev.Revision version = "r" & revision modified = 0 @@ -124,7 +124,7 @@ Function DetermineSVNVersion() WshShell.Environment("PROCESS")("LANG") = "en" ' Do we have subversion installed? Check immediatelly whether we've got a modified WC. - Set oExec = WshShell.Exec("svnversion ../src") + Set oExec = WshShell.Exec("svnversion ../") If Err.Number = 0 Then ' Wait till the application is finished ... Do While oExec.Status = 0 @@ -137,7 +137,7 @@ Function DetermineSVNVersion() End If ' And use svn info to get the correct revision and branch information. - Set oExec = WshShell.Exec("svn info ../src") + Set oExec = WshShell.Exec("svn info ../") If Err.Number = 0 Then Do line = OExec.StdOut.ReadLine() @@ -179,7 +179,7 @@ Function DetermineSVNVersion() WScript.Sleep 10 Loop End If - Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../src") + Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../") If Err.Number = 0 Then ' Wait till the application is finished ... Do While oExec.Status = 0 @@ -198,7 +198,7 @@ Function DetermineSVNVersion() End If ' line <> "master" End If ' Err.Number = 0 - Set oExec = WshShell.Exec("git log --pretty=format:%s --grep=" & Chr(34) & "^(svn r[0-9]*)" & Chr(34) & " -1 ../src") + Set oExec = WshShell.Exec("git log --pretty=format:%s --grep=" & Chr(34) & "^(svn r[0-9]*)" & Chr(34) & " -1 ../") if Err.Number = 0 Then revision = Mid(oExec.StdOut.ReadLine(), 7) revision = Mid(revision, 1, InStr(revision, ")") - 1) @@ -207,7 +207,7 @@ Function DetermineSVNVersion() ' 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") + Set oExec = WshShell.Exec("git log --pretty=format:%b --grep=" & Chr(34) & "git-svn-id:.*@[0-9]*" & Chr(34) & " -1 ../") If Err.Number = 0 Then revision = oExec.StdOut.ReadLine() revision = Mid(revision, InStr(revision, "@") + 1) @@ -231,7 +231,7 @@ Function DetermineSVNVersion() line = OExec.StdOut.ReadLine() hash = Mid(line, InStrRev(line, ":") + 1) version = "h" & Mid(hash, 1, 8) - Set oExec = WshShell.Exec("hg status ../src") + Set oExec = WshShell.Exec("hg status ../") If Err.Number = 0 Then Do line = OExec.StdOut.ReadLine() @@ -249,7 +249,7 @@ Function DetermineSVNVersion() End If ' line <> "default" End If ' Err.Number = 0 - Set oExec = WshShell.Exec("hg log -r " & hash & ":0 -k " & Chr(34) & "svn" & Chr(34) & " -l 1 --template " & Chr(34) & "{desc}\n" & Chr(34) & " ../src") + Set oExec = WshShell.Exec("hg log -r " & hash & ":0 -k " & Chr(34) & "svn" & Chr(34) & " -l 1 --template " & Chr(34) & "{desc}\n" & Chr(34) & " ../") If Err.Number = 0 Then revision = Mid(OExec.StdOut.ReadLine(), 7) revision = Mid(revision, 1, InStr(revision, ")") - 1)