Changeset - r7917:a6fa3e1c2370
[Not reviewed]
master
0 1 0
glx - 17 years ago 2007-11-18 22:39:02
glx@openttd.org
(svn r11470) -Codechange: add git detection to MSVC (michi_cc)
1 file changed with 35 insertions and 2 deletions:
0 comments (0 inline, 0 general)
projects/determineversion.vbs
Show inline comments
 
@@ -41,6 +41,12 @@ Sub UpdateFiles(version)
 
				revision = Mid(OExec.StdOut.ReadLine(), 7)
 
				revision = Mid(revision, 1, InStr(revision, ")") - 1)
 
			End If
 
		Case "g" ' git
 
			Set oExec = WshShell.Exec("git log --pretty=format:%s --grep=" & Chr(34) & "^(svn r[0-9]*)" & Chr(34) & " -1 ../src")
 
			if Err.Number = 0 Then
 
				revision = Mid(oExec.StdOut.ReadLine(), 7)
 
				revision = Mid(revision, 1, InStr(revision, ")") - 1)
 
			End If
 
	End Select
 

	
 
	UpdateFile revision, version, cur_date, "../src/rev.cpp"
 
@@ -118,7 +124,31 @@ Function DetermineSVNVersion()
 
			version = version & Replace(url, "/", "-")
 
		End If
 
	Else
 
		' svn detection failed, reset error and try mercurial (hg)
 
		' svn detection failed, reset error and try git
 
		Err.Clear
 
		Set oExec = WshShell.Exec("git rev-parse --verify --short=8 HEAD")
 
		Do While oExec.Status = 0 And Err.Number = 0
 
			' Wait till command has finished
 
		Loop
 
		If Err.Number = 0 And oExec.ExitCode = 0 Then
 
			version = "g" & oExec.StdOut.ReadLine()
 
			Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../src")
 
			Do While oExec.Status = 0 And Err.Number = 0
 
			Loop
 
			If Err.Number = 0 And oExec.ExitCode = 1 Then
 
				version = version & "M"
 
			End If
 

	
 
			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
 
					version = version & "-" & line
 
				End If
 
			End If
 
		Else
 
			' try mercurial (hg)
 
		Err.Clear
 
		Set oExec = WshShell.Exec("hg tip")
 
		If Err.Number = 0 Then
 
@@ -136,7 +166,10 @@ Function DetermineSVNVersion()
 
			Set oExec = WshShell.Exec("hg branch")
 
			If Err.Number = 0 Then
 
					line = OExec.StdOut.ReadLine()
 
					If line <> "default" Then version = version & "-" & line
 
						If line <> "default" Then
 
							version = version & "-" & line
 
						End If
 
				End If
 
			End If
 
		End If
 
	End If
0 comments (0 inline, 0 general)