Changeset - r17092:68ea7f31e57c
[Not reviewed]
master
0 2 0
michi_cc - 14 years ago 2011-01-18 21:27:30
michi_cc@openttd.org
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
2 files changed with 20 insertions and 2 deletions:
0 comments (0 inline, 0 general)
findversion.sh
Show inline comments
 
@@ -90,24 +90,29 @@ elif [ -d "$ROOT_DIR/.git" ]; then
 
	git update-index --refresh >/dev/null
 
	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 | 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 | sed "s@.*\@\([0-9]*\).*@\1@"`
 
	fi
 
	TAG=`git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null`
 
	if [ -n "$TAG" ]; then
 
		BRANCH=""
 
		REV=$TAG
 
	fi
 
elif [ -d "$ROOT_DIR/.hg" ]; then
 
	# We are a hg checkout
 
	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 -f -k "(svn r" -l 1 --template "{desc}\n" | head -n 1 | sed "s@.*(svn r\([0-9]*\)).*@\1@"`
 
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
 
	# We are an exported source bundle
 
	cat $ROOT_DIR/.ottdrev
projects/determineversion.vbs
Show inline comments
 
@@ -192,40 +192,53 @@ Function DetermineSVNVersion()
 
						modified = 2
 
					End If ' oExec.ExitCode = 1
 

	
 
					Set oExec = WshShell.Exec("git symbolic-ref HEAD")
 
					If Err.Number = 0 Then
 
						line = oExec.StdOut.ReadLine()
 
						line = Mid(line, InStrRev(line, "/") + 1)
 
						If line <> "master" Then
 
							branch = line
 
						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 ../")
 
					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)
 
					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 ../")
 
						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)
 
							revision = Mid(revision, 1, InStr(revision, " ") - 1)
 
						End If ' Err.Number = 0
 
					End If ' revision = ""
 

	
 
					' Check if a tag is currently checked out
 
					Err.Clear
 
					Set oExec = WshShell.Exec("git name-rev --name-only --tags --no-undefined HEAD")
 
					If Err.Number = 0 Then
 
						' Wait till the application is finished ...
 
						Do While oExec.Status = 0
 
						Loop
 
						If oExec.ExitCode = 0 Then
 
							version = oExec.StdOut.ReadLine()
 
							branch = ""
 
						End If ' oExec.ExitCode = 0
 
					End If ' Err.Number = 0
 
				End If ' Err.Number = 0
 
			End If ' oExec.ExitCode = 0
 
		End If ' Err.Number = 0
 

	
 
		If version = "norev000" Then
 
			' git detection failed, reset error and try mercurial (hg)
 
			Err.Clear
 
			Set oExec = WshShell.Exec("hg parents")
 
			If Err.Number = 0 Then
 
				' Wait till the application is finished ...
 
				Do While oExec.Status = 0
 
				Loop
0 comments (0 inline, 0 general)