1
0
Fork 0

Change: Non-tag revisions are now named '<commitdate>-<branch>-g<shorthash><modified>'.

pull/6709/head
frosch 2018-04-12 20:59:03 +02:00 committed by frosch
parent e0a62a9e55
commit 192770e6da
6 changed files with 139 additions and 367 deletions

View File

@ -12,15 +12,15 @@
# The revision is needed for the bundle name and creating an OSX application bundle. # The revision is needed for the bundle name and creating an OSX application bundle.
# Detect the revision # Detect the revision
VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh") VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
REV := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ') VERSION := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
# Make sure we have something in REV # Make sure we have something in VERSION
ifeq ($(REV),) ifeq ($(VERSION),)
REV := norev000 VERSION := norev000
endif endif
ifndef BUNDLE_NAME ifndef BUNDLE_NAME
BUNDLE_NAME = openttd-custom-$(REV)-$(OS) BUNDLE_NAME = openttd-custom-$(VERSION)-$(OS)
endif endif
# An OSX application bundle needs the data files, lang files and openttd executable in a different location. # An OSX application bundle needs the data files, lang files and openttd executable in a different location.

View File

@ -94,15 +94,15 @@ VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
MODIFIED := $(shell echo "$(VERSIONS)" | cut -f 3 -d' ') MODIFIED := $(shell echo "$(VERSIONS)" | cut -f 3 -d' ')
# Use autodetected revisions # Use autodetected revisions
REV := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ') VERSION := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
REV_NR := $(shell echo "$(VERSIONS)" | cut -f 2 -d' ') ISODATE := $(shell echo "$(VERSIONS)" | cut -f 2 -d' ')
# Make sure we have something in REV and REV_NR # Make sure we have something in VERSION and ISODATE
ifeq ($(REV),) ifeq ($(VERSION),)
REV := norev000 VERSION := norev000
endif endif
ifeq ($(REV_NR),) ifeq ($(ISODATE),)
REV_NR := 0 ISODATE := 00000000
endif endif
# This helps to recompile if flags change # This helps to recompile if flags change
@ -113,7 +113,7 @@ RES := $(shell if [ "`cat $(CONFIG_CACHE_ENDIAN) 2>/dev/null`" != "$(ENDIAN_FORC
# If there is a change in the source-file-list, make sure we recheck the deps # If there is a change in the source-file-list, make sure we recheck the deps
RES := $(shell if [ "`cat $(CONFIG_CACHE_SOURCE) 2>/dev/null`" != "$(SRCS)" ]; then echo "$(SRCS)" > $(CONFIG_CACHE_SOURCE); fi ) RES := $(shell if [ "`cat $(CONFIG_CACHE_SOURCE) 2>/dev/null`" != "$(SRCS)" ]; then echo "$(SRCS)" > $(CONFIG_CACHE_SOURCE); fi )
# If there is a change in the revision, make sure we recompile rev.cpp # If there is a change in the revision, make sure we recompile rev.cpp
RES := $(shell if [ "`cat $(CONFIG_CACHE_VERSION) 2>/dev/null`" != "$(REV) $(MODIFIED)" ]; then echo "$(REV) $(MODIFIED)" > $(CONFIG_CACHE_VERSION); fi ) RES := $(shell if [ "`cat $(CONFIG_CACHE_VERSION) 2>/dev/null`" != "$(VERSION) $(MODIFIED)" ]; then echo "$(VERSION) $(MODIFIED)" > $(CONFIG_CACHE_VERSION); fi )
ifndef MAKEDEPEND ifndef MAKEDEPEND
# The slow, but always correct, dep-check # The slow, but always correct, dep-check
@ -293,10 +293,10 @@ $(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp
# Revision files # Revision files
$(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/rev.cpp.in $(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/rev.cpp.in
$(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s@\!\!REVISION\!\!@$(REV_NR)@g;s@!!VERSION!!@$(REV)@g;s@!!MODIFIED!!@$(MODIFIED)@g;s@!!DATE!!@`date +%d.%m.%y`@g" > $(SRC_DIR)/rev.cpp $(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!MODIFIED!!@$(MODIFIED)@g;s@!!DATE!!@`date +%d.%m.%y`@g" > $(SRC_DIR)/rev.cpp
$(SRC_DIR)/os/windows/ottdres.rc: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/os/windows/ottdres.rc.in $(SRC_DIR)/os/windows/ottdres.rc: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/os/windows/ottdres.rc.in
$(Q)cat $(SRC_DIR)/os/windows/ottdres.rc.in | sed "s@\!\!REVISION\!\!@$(REV_NR)@g;s@!!VERSION!!@$(REV)@g;s@!!DATE!!@`date +%d.%m.%y`@g" > $(SRC_DIR)/os/windows/ottdres.rc $(Q)cat $(SRC_DIR)/os/windows/ottdres.rc.in | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!DATE!!@`date +%d.%m.%y`@g" > $(SRC_DIR)/os/windows/ottdres.rc
FORCE: FORCE:

View File

@ -14,42 +14,31 @@ if [ "$#" != "0" ]; then
Usage: ./findversion.sh Usage: ./findversion.sh
Finds the current revision and if the code is modified. Finds the current revision and if the code is modified.
Output: <REV>\t<REV_NR>\t<MODIFIED>\t<CLEAN_REV> Output: <VERSION>\t<ISODATE>\t<MODIFIED>\t<HASH>
REV VERSION
a string describing what version of the code the current checkout is a string describing what version of the code the current checkout is
based on. The exact format of this string depends on the version based on.
control system in use, but it tries to identify the revision used as This also includes the commit date, an indication of whether the checkout
close as possible (using the svn revision number or hg/git hash). was modified and which branch was checked out. This value is not
This also includes an indication of whether the checkout was
modified and which branch was checked out. This value is not
guaranteed to be sortable, but is mainly meant for identifying the guaranteed to be sortable, but is mainly meant for identifying the
revision and user display. revision and user display.
If no revision identifier could be found, this is left empty. If no revision identifier could be found, this is left empty.
REV_NR ISODATE
the revision number of the svn revision this checkout is based on. the commit date of the revision this checkout is based on.
This can be used to determine which functionality is present in this The commit date may differ from the author date.
checkout. For trunk svn checkouts and hg/git branches based upon it, This can be used to decide upon the age of the source.
this number should be accurate. For svn branch checkouts, this
number is mostly meaningless, at least when comparing with the
REV_NR from other branches or trunk.
This number should be sortable. Within a given branch or trunk, a If no timestamp could be found, this is left empty.
higher number means a newer version. However, when using git or hg,
this number will not increase on new commits.
If no revision number could be found, this is left empty.
MODIFIED MODIFIED
Whether (the src directory of) this checkout is modified or not. A Whether (the src directory of) this checkout is modified or not. A
value of 0 means not modified, a value of 2 means it was modified. value of 0 means not modified, a value of 2 means it was modified.
Modification is determined in relation to the commit identified by
REV, so not in relation to the svn revision identified by REV_NR.
A value of 1 means that the modified status is unknown, because this A value of 1 means that the modified status is unknown, because this
is not an svn/git/hg checkout for example. is not an git checkout for example.
CLEAN_REV HASH
the same as REV but without branch name the git revision hash
By setting the AWK environment variable, a caller can determine which By setting the AWK environment variable, a caller can determine which
version of "awk" is used. If nothing is set, this script defaults to version of "awk" is used. If nothing is set, this script defaults to
@ -70,21 +59,7 @@ ROOT_DIR=`pwd`
# Determine if we are using a modified version # Determine if we are using a modified version
# Assume the dir is not modified # Assume the dir is not modified
MODIFIED="0" MODIFIED="0"
if [ -d "$ROOT_DIR/.svn" ] || [ -d "$ROOT_DIR/../.svn" ]; then if [ -d "$ROOT_DIR/.git" ]; then
# We are an svn checkout
if [ -n "`svnversion | grep 'M'`" ]; then
MODIFIED="2"
fi
# Find the revision like: rXXXXM-branch
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
REV="r$REV_NR"
fi
elif [ -d "$ROOT_DIR/.git" ]; then
# We are a git checkout # We are a git checkout
# Refresh the index to make sure file stat info is in sync, then look for modifications # Refresh the index to make sure file stat info is in sync, then look for modifications
git update-index --refresh >/dev/null git update-index --refresh >/dev/null
@ -92,35 +67,21 @@ elif [ -d "$ROOT_DIR/.git" ]; then
MODIFIED="2" MODIFIED="2"
fi fi
HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null` HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
REV="g`echo $HASH | cut -c1-8`" SHORTHASH=`echo ${HASH} | cut -c1-8`
ISODATE=`LC_ALL=C git show -s --pretty='format:%ci' HEAD | "$AWK" '{ gsub("-", "", $1); print $1 }'`
BRANCH="`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@;s@^master$@@'`" 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 | sed 's@\^0$@@'`" TAG="`git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed 's@\^0$@@'`"
if [ -n "$TAG" ]; then if [ -n "$TAG" ]; then
BRANCH="" VERSION="${TAG}"
REV="$TAG" elif [ "${BRANCH}" = "master" ]; then
VERSION="${ISODATE}-g${SHORTHASH}"
else
VERSION="${ISODATE}-${BRANCH}-g${SHORTHASH}"
fi fi
elif [ -d "$ROOT_DIR/.hg" ]; then
# We are a hg checkout if [ "$MODIFIED" -eq "2" ]; then
if [ -n "`HGPLAIN= hg status | grep -v '^?'`" ]; then VERSION="${VERSION}M"
MODIFIED="2"
fi
HASH=`LC_ALL=C HGPLAIN= hg id -i | cut -c1-12`
REV="h`echo $HASH | cut -c1-8`"
BRANCH="`HGPLAIN= hg branch | sed 's@^default$@@'`"
TAG="`HGPLAIN= hg id -t | grep -v 'tip$'`"
if [ -n "$TAG" ]; then
BRANCH=""
REV="$TAG"
fi
REV_NR=`LC_ALL=C HGPLAIN= hg log -f -k "(svn r" -l 1 --template "{desc|firstline}\n" | grep "^(svn r[0-9]*)" | sed "s@.*(svn r\([0-9]*\)).*@\1@"`
if [ -z "$REV_NR" ]; then
# No rev? Maybe it is a custom hgsubversion clone
REV_NR=`LC_ALL=C HGPLAIN= hg parent --template="{svnrev}"`
fi fi
elif [ -f "$ROOT_DIR/.ottdrev" ]; then elif [ -f "$ROOT_DIR/.ottdrev" ]; then
# We are an exported source bundle # We are an exported source bundle
@ -129,19 +90,12 @@ elif [ -f "$ROOT_DIR/.ottdrev" ]; then
else else
# We don't know # We don't know
MODIFIED="1" MODIFIED="1"
HASH=""
SHORTHASH=""
BRANCH="" BRANCH=""
REV="" ISODATE=""
REV_NR="" TAG=""
VERSION=""
fi fi
if [ "$MODIFIED" -eq "2" ]; then echo "$VERSION $ISODATE $MODIFIED $HASH"
REV="${REV}M"
fi
CLEAN_REV=${REV}
if [ -n "$BRANCH" ]; then
REV="${REV}-$BRANCH"
fi
echo "$REV $REV_NR $MODIFIED $CLEAN_REV"

View File

@ -21,312 +21,132 @@ Sub FindReplaceInFile(filename, to_find, replacement)
file.Close file.Close
End Sub End Sub
Sub UpdateFile(modified, revision, version, cur_date, filename) Sub UpdateFile(modified, isodate, version, cur_date, filename)
FSO.CopyFile filename & ".in", filename FSO.CopyFile filename & ".in", filename
FindReplaceInFile filename, "!!MODIFIED!!", modified FindReplaceInFile filename, "!!MODIFIED!!", modified
FindReplaceInFile filename, "!!REVISION!!", revision FindReplaceInFile filename, "!!ISODATE!!", isodate
FindReplaceInFile filename, "!!VERSION!!", version FindReplaceInFile filename, "!!VERSION!!", version
FindReplaceInFile filename, "!!DATE!!", cur_date FindReplaceInFile filename, "!!DATE!!", cur_date
End Sub End Sub
Sub UpdateFiles(version) Sub UpdateFiles(version)
Dim modified, revision, cur_date Dim modified, isodate, cur_date
cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date) cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date)
If InStr(version, Chr(9)) Then If InStr(version, Chr(9)) Then
revision = Mid(version, InStr(version, Chr(9)) + 1) isodate = Mid(version, InStr(version, Chr(9)) + 1)
modified = Mid(revision, InStr(revision, Chr(9)) + 1) modified = Mid(isodate, InStr(isodate, Chr(9)) + 1)
revision = Mid(revision, 1, InStr(revision, Chr(9)) - 1) isodate = Mid(isodate, 1, InStr(isodate, Chr(9)) - 1)
modified = Mid(modified, 1, InStr(modified, Chr(9)) - 1) modified = Mid(modified, 1, InStr(modified, Chr(9)) - 1)
version = Mid(version, 1, InStr(version, Chr(9)) - 1) version = Mid(version, 1, InStr(version, Chr(9)) - 1)
Else Else
revision = 0 isodate = 0
modified = 1 modified = 1
End If End If
UpdateFile modified, revision, version, cur_date, "../src/rev.cpp" UpdateFile modified, isodate, version, cur_date, "../src/rev.cpp"
UpdateFile modified, revision, version, cur_date, "../src/os/windows/ottdres.rc" UpdateFile modified, isodate, version, cur_date, "../src/os/windows/ottdres.rc"
End Sub End Sub
Function ReadRegistryKey(shive, subkey, valuename, architecture) Function DetermineVersion()
Dim hiveKey, objCtx, objLocator, objServices, objReg, Inparams, Outparams Dim WshShell, branch, tag, modified, isodate, oExec, line, hash, shorthash
' First, get the Registry Provider for the requested architecture
Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
objCtx.Add "__ProviderArchitecture", architecture ' Must be 64 of 32
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx)
Set objReg = objServices.Get("StdRegProv")
' Check the hive and give it the right value
Select Case shive
Case "HKCR", "HKEY_CLASSES_ROOT"
hiveKey = &h80000000
Case "HKCU", "HKEY_CURRENT_USER"
hiveKey = &H80000001
Case "HKLM", "HKEY_LOCAL_MACHINE"
hiveKey = &h80000002
Case "HKU", "HKEY_USERS"
hiveKey = &h80000003
Case "HKCC", "HKEY_CURRENT_CONFIG"
hiveKey = &h80000005
Case "HKDD", "HKEY_DYN_DATA" ' Only valid for Windows 95/98
hiveKey = &h80000006
Case Else
MsgBox "Hive not valid (ReadRegistryKey)"
End Select
Set Inparams = objReg.Methods_("GetStringValue").Inparameters
Inparams.Hdefkey = hiveKey
Inparams.Ssubkeyname = subkey
Inparams.Svaluename = valuename
Set Outparams = objReg.ExecMethod_("GetStringValue", Inparams,,objCtx)
ReadRegistryKey = Outparams.SValue
End Function
Function DetermineSVNVersion()
Dim WshShell, version, branch, modified, revision, clean_rev, url, oExec, line, hash
Set WshShell = CreateObject("WScript.Shell") Set WshShell = CreateObject("WScript.Shell")
On Error Resume Next On Error Resume Next
revision = 0 modified = 1
hash = ""
shorthash = ""
branch = ""
isodate = ""
tag = ""
' Try TortoiseSVN ' Set the environment to english
' Get the directory where TortoiseSVN (should) reside(s) WshShell.Environment("PROCESS")("LANG") = "en"
Dim sTortoise
' First, try with 32-bit architecture
sTortoise = ReadRegistryKey("HKLM", "SOFTWARE\TortoiseSVN", "Directory", 32)
If sTortoise = "" Or IsNull(sTortoise) Then
' No 32-bit version of TortoiseSVN installed, try 64-bit version (doesn't hurt on 32-bit machines, it returns nothing or is ignored)
sTortoise = ReadRegistryKey("HKLM", "SOFTWARE\TortoiseSVN", "Directory", 64)
End If
' If TortoiseSVN is installed, try to get the revision number Set oExec = WshShell.Exec("git rev-parse --verify HEAD")
If sTortoise <> "" Then If Err.Number = 0 Then
Dim SubWCRev ' Wait till the application is finished ...
Set SubWCRev = WScript.CreateObject("SubWCRev.object") Do While oExec.Status = 0
SubWCRev.GetWCInfo FSO.GetAbsolutePathName("../"), 0, 0 Loop
revision = SubWCRev.Revision
version = "r" & revision
modified = 0
if SubWCRev.HasModifications then modified = 2
url = SubWCRev.Url
End If
' Looks like there is no TortoiseSVN installed either. Then we don't know it. If oExec.ExitCode = 0 Then
If revision = 0 Then hash = oExec.StdOut.ReadLine()
' Reset error and version shorthash = Mid(hash, 1, 8)
Err.Clear ' Make sure index is in sync with disk
version = "norev000" Set oExec = WshShell.Exec("git update-index --refresh")
modified = 0 If Err.Number = 0 Then
' StdOut and StdErr share a 4kB buffer so prevent it from filling up as we don't care about the output
' Set the environment to english oExec.StdOut.Close
WshShell.Environment("PROCESS")("LANG") = "en" oExec.StdErr.Close
' Wait till the application is finished ...
' Do we have subversion installed? Check immediatelly whether we've got a modified WC. Do While oExec.Status = 0
Set oExec = WshShell.Exec("svnversion ../") WScript.Sleep 10
If Err.Number = 0 Then Loop
' Wait till the application is finished ... End If
Do While oExec.Status = 0 Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../")
Loop
line = OExec.StdOut.ReadLine()
If line <> "exported" Then
If InStr(line, "M") Then
modified = 2
End If
' And use svn info to get the correct revision and branch information.
Set oExec = WshShell.Exec("svn info ../")
If Err.Number = 0 Then
Do
line = OExec.StdOut.ReadLine()
If InStr(line, "URL") Then
url = line
End If
If InStr(line, "Last Changed Rev") Then
revision = Mid(line, 19)
version = "r" & revision
End If
Loop While Not OExec.StdOut.atEndOfStream
End If ' Err.Number = 0
End If ' line <> "exported"
End If ' Err.Number = 0
End If ' InStr(version, "$")
If version <> "norev000" Then
If InStr(url, "branches") Then
branch = Mid(url, InStr(url, "branches/") + 9)
End If
If InStr(url, "tags") Then
version = Mid(url, InStr(url, "tags/") + 5)
End If
Else ' version <> "norev000"
' svn detection failed, reset error and try git
Err.Clear
Set oExec = WshShell.Exec("git rev-parse --verify HEAD")
If Err.Number = 0 Then
' Wait till the application is finished ...
Do While oExec.Status = 0
Loop
If oExec.ExitCode = 0 Then
hash = oExec.StdOut.ReadLine()
version = "g" & Mid(hash, 1, 8)
' Make sure index is in sync with disk
Set oExec = WshShell.Exec("git update-index --refresh")
If Err.Number = 0 Then
' StdOut and StdErr share a 4kB buffer so prevent it from filling up as we don't care about the output
oExec.StdOut.Close
oExec.StdErr.Close
' Wait till the application is finished ...
Do While oExec.Status = 0
WScript.Sleep 10
Loop
End If
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
Loop
If oExec.ExitCode = 1 Then
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")
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")
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()
If Right(version, 2) = "^0" Then
version = Left(version, Len(version) - 2)
End If
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 id -i")
If Err.Number = 0 Then If Err.Number = 0 Then
' Wait till the application is finished ... ' Wait till the application is finished ...
Do While oExec.Status = 0 Do While oExec.Status = 0
Loop Loop
If oExec.ExitCode = 0 Then If oExec.ExitCode = 1 Then
line = OExec.StdOut.ReadLine() modified = 2
hash = Left(line, 12) End If ' oExec.ExitCode = 1
version = "h" & Mid(hash, 1, 8)
' Check if a tag is currently checked out Set oExec = WshShell.Exec("git show -s --pretty=format:%ci")
Err.Clear if Err.Number = 0 Then
Set oExec = WshShell.Exec("hg id -t") isodate = Mid(oExec.StdOut.ReadLine(), 1, 10)
If Err.Number = 0 Then isodate = Replace(isodate, "-", "")
line = oExec.StdOut.ReadLine() End If ' Err.Number = 0
If Len(line) > 0 And Right(line, 3) <> "tip" Then
version = line
branch = ""
End If ' Len(line) > 0 And Right(line, 3) <> "tip"
End If ' Err.Number = 0
Err.Clear ' Check branch
Set oExec = WshShell.Exec("hg status ../") Err.Clear
If Err.Number = 0 Then Set oExec = WshShell.Exec("git symbolic-ref HEAD")
Do If Err.Number = 0 Then
line = OExec.StdOut.ReadLine() line = oExec.StdOut.ReadLine()
If Len(line) > 0 And Mid(line, 1, 1) <> "?" Then branch = Mid(line, InStrRev(line, "/") + 1)
modified = 2 End If ' Err.Number = 0
Exit Do
End If ' Len(line) > 0 And Mid(line, 1, 1) <> "?"
Loop While Not OExec.StdOut.atEndOfStream
Set oExec = WshShell.Exec("hg branch") ' Check if a tag is currently checked out
If Err.Number = 0 Then Err.Clear
line = OExec.StdOut.ReadLine() Set oExec = WshShell.Exec("git name-rev --name-only --tags --no-undefined HEAD")
If line <> "default" Then If Err.Number = 0 Then
branch = line ' Wait till the application is finished ...
End If ' line <> "default" Do While oExec.Status = 0
End If ' Err.Number = 0 Loop
If oExec.ExitCode = 0 Then
Set oExec = WshShell.Exec("hg log -f -k " & Chr(34) & "(svn r" & Chr(34) & " -l 1 --template " & Chr(34) & "{desc|firstline}\n" & Chr(34) & " --cwd ../") tag = oExec.StdOut.ReadLine()
If Err.Number = 0 Then If Right(tag, 2) = "^0" Then
line = oExec.StdOut.ReadLine() tag = Left(tag, Len(tag) - 2)
If Left(line, 6) = "(svn r" Then End If
revision = Mid(line, 7) End If ' oExec.ExitCode = 0
revision = Mid(revision, 1, InStr(revision, ")") - 1) End If ' Err.Number = 0
End If 'Left(line, 6) = "(svn r"
End If ' Err.Number = 0
If revision = "" Then
' No rev? Maybe it is a custom hgsubversion clone
Err.Clear
Set oExec = WshShell.Exec("hg parent --template=" & Chr(34) & "{svnrev}" & Chr(34))
If Err.Number = 0 Then
revision = oExec.StdOut.ReadLine()
End If ' Err.Number = 0
End If ' revision = ""
End If ' Err.Number = 0
End If ' oExec.ExitCode = 0
End If ' Err.Number = 0 End If ' Err.Number = 0
End If ' version = "norev000" End If ' oExec.ExitCode = 0
End If ' version <> "norev000" End If ' Err.Number = 0
If version = "norev000" And FSO.FileExists("../.ottdrev") Then If hash = "" And FSO.FileExists("../.ottdrev") Then
Dim rev_file Dim rev_file
Set rev_file = FSO.OpenTextFile("../.ottdrev", 1, True, 0) Set rev_file = FSO.OpenTextFile("../.ottdrev", 1, True, 0)
DetermineSVNVersion = rev_file.ReadLine() DetermineVersion = rev_file.ReadLine()
rev_file.Close() rev_file.Close()
ElseIf hash = "" Then
DetermineVersion = "norev000"
Else Else
Dim version
If tag <> "" Then
version = tag
ElseIf branch = "master" Then
version = isodate & "-g" & shorthash
Else
version = isodate & "-" & branch & "-g" & shorthash
End If
If modified = 2 Then If modified = 2 Then
version = version & "M" version = version & "M"
End If End If
clean_rev = version DetermineVersion = version & Chr(9) & isodate & Chr(9) & modified & Chr(9) & hash
If branch <> "" Then
version = version & "-" & branch
End If
If version <> "norev000" Then
DetermineSVNVersion = version & Chr(9) & revision & Chr(9) & modified & Chr(9) & clean_rev
Else
DetermineSVNVersion = version
End If
End If End If
End Function End Function
@ -359,7 +179,7 @@ Function CheckFile(filename)
End Function End Function
Dim version Dim version
version = DetermineSVNVersion version = DetermineVersion
If Not (IsCachedVersion(version) And CheckFile("../src/rev.cpp") And CheckFile("../src/os/windows/ottdres.rc")) Then If Not (IsCachedVersion(version) And CheckFile("../src/rev.cpp") And CheckFile("../src/os/windows/ottdres.rc")) Then
UpdateFiles version UpdateFiles version
End If End If

View File

@ -79,8 +79,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,9,0,!!REVISION!! FILEVERSION 1,9,0,!!ISODATE!!
PRODUCTVERSION 1,9,0,!!REVISION!! PRODUCTVERSION 1,9,0,!!ISODATE!!
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L

View File

@ -26,18 +26,16 @@ bool IsReleasedVersion()
/** /**
* The text version of OpenTTD's revision. * The text version of OpenTTD's revision.
* This will be either "<major>.<minor>.<build>[-RC<rc>]", * This will be either
* "r<revision number>[M][-<branch>]" or "norev000". * - "<tag>", like "<major>.<minor>.<build>[-RC<rc>]",
* - "<commitdate>-g<shorthash><modified>" in "master",
* - "<commitdate>-<branch>-g<shorthash><modified>" in other branches, or
* - "norev000", if the version is unknown.
* *
* The major, minor and build are the numbers that describe releases of * The major, minor and build are the numbers that describe releases of
* OpenTTD (like 0.5.3). "-RC" is used to flag release candidates. * OpenTTD (like 0.5.3). "-RC" is used to flag release candidates.
* *
* The revision number is fairly straight forward. The M is to show that * <modified> shows a "M", if the binary is made from modified source code.
* the binary is made from modified source code. The branch shows the
* branch the revision is of and will not be there when it is trunk.
*
* norev000 is for non-releases that are made on systems without
* subversion or sources that are not a checkout of subversion.
*/ */
const char _openttd_revision[] = "!!VERSION!!"; const char _openttd_revision[] = "!!VERSION!!";