summaryrefslogtreecommitdiff
path: root/projects
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2007-11-18 22:39:02 +0000
committerglx <glx@openttd.org>2007-11-18 22:39:02 +0000
commit6097c07e4b77f72fdb17261ea6616f729265c2a2 (patch)
tree25c2e42bb5523db2f9ea85d9495506d46b3deed7 /projects
parent400ca1dae52248ca567d5e3145c554fcad61927a (diff)
downloadopenttd-6097c07e4b77f72fdb17261ea6616f729265c2a2.tar.xz
(svn r11470) -Codechange: add git detection to MSVC (michi_cc)
Diffstat (limited to 'projects')
-rw-r--r--projects/determineversion.vbs63
1 files changed, 48 insertions, 15 deletions
diff --git a/projects/determineversion.vbs b/projects/determineversion.vbs
index 4576e3b23..8f9b24d40 100644
--- a/projects/determineversion.vbs
+++ b/projects/determineversion.vbs
@@ -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,25 +124,52 @@ 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("hg tip")
- If Err.Number = 0 Then
- version = "h" & Mid(OExec.StdOut.ReadLine(), 19, 8)
- Set oExec = WshShell.Exec("hg status ../src")
+ 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
- Do
- line = OExec.StdOut.ReadLine()
- If Mid(line, 1, 1) <> "?" Then
- version = version & "M"
- Exit Do
- End If
- Loop While Not OExec.StdOut.atEndOfStream
+ line = oExec.StdOut.ReadLine()
+ line = Mid(line, InStrRev(line, "/")+1)
+ If line <> "master" Then
+ version = version & "-" & line
+ End If
End If
- Set oExec = WshShell.Exec("hg branch")
+ Else
+ ' try mercurial (hg)
+ Err.Clear
+ Set oExec = WshShell.Exec("hg tip")
If Err.Number = 0 Then
- line = OExec.StdOut.ReadLine()
- If line <> "default" Then version = version & "-" & line
+ version = "h" & Mid(OExec.StdOut.ReadLine(), 19, 8)
+ Set oExec = WshShell.Exec("hg status ../src")
+ If Err.Number = 0 Then
+ Do
+ line = OExec.StdOut.ReadLine()
+ If Mid(line, 1, 1) <> "?" Then
+ version = version & "M"
+ Exit Do
+ End If
+ Loop While Not OExec.StdOut.atEndOfStream
+ End If
+ Set oExec = WshShell.Exec("hg branch")
+ If Err.Number = 0 Then
+ line = OExec.StdOut.ReadLine()
+ If line <> "default" Then
+ version = version & "-" & line
+ End If
+ End If
End If
End If
End If