The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Simutrans-Extended bug reports => Topic started by: Matthew on December 13, 2020, 08:49:04 PM

Title: Extended client reports Standard revision number
Post by: Matthew on December 13, 2020, 08:49:04 PM
Steps to reproduce

1. Start the Simutrans-Extended client using a build from 2020-12-13 or later using Windows 10 and with logging turned on
2. Observe that the title bar displays a Standard revision number (currently #9499)
3. Open simu.log and observe that the first line records the same Standard revision number

Expected outcome: Extended reports the Git commit hash of the current build.

This change was probably made by this commit (https://github.com/jamespetts/simutrans-extended/commit/164060ed31f6c9b93fad6ed9c2dbcccd0157e3e8#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52).

By the way, I started to prepare a report concerning a different possible bug in the commit hash code earlier this year. I eventually realized that the error I was investigating was caused by a configuration error that I made. But if you are trying to fix the bug above and see a "Git output not valid!" error message, then the following notes may help. if you don't see that message, you can ignore everything below this line.

-------------------------------------------------------------

1>git : Not a git repository warning GitNR0: Git output not valid! Check if the folder is actually versioned. Revision number will be set to zero. You won't be able to play online with this build.

This error message is not the similar one generated by Git itself, but is produced by Sim-Ex's revision.jse file. Neither VS nor VSCode recognized the language of this file. It appears to be an ActiveX control run by cscript (the command-line version of the Windows Scripting Host), but the same function names are used by many Microsoft languages, so I'm not certain.

If I understand revision.jse correctly (which is a dubious assumption), this particular error message is triggered by this snippet of code:
// Try to get revision number
try {
var gitRevNum = shell.Exec("git rev-parse --short=7 HEAD");
rev           = gitRevNum.StdOut.ReadAll();

// Check if Git output is valid
if (rev.length !== 9) {
WSH.Echo("git : Not a git repository warning GitNR" + errorcode + ":Git output not valid! Check if the folder is actually versioned." + errormsg);
rev = 0;
}
}


I ran the git rev-parse --short=7 HEAD command in cmd.exe and it produces a revision number truncated to 7 characters (as instructed by short=7) from the latest Git commit hash (which is 9 characters). So it seems that this test is guaranteed to fail. The truncation was introduced by AndrewCarlotti in this commit (https://github.com/jamespetts/simutrans-extended/commit/77530e1add29839f222b7c68879efe383f935c19#diff-1de670721742a90619fe341dbe85445aaf38719d3fceb1fab966b57cf0aff93c).

Title: Re: Extended client reports Standard revision number
Post by: prissi on December 14, 2020, 02:27:43 AM
In the git commit you linked first, just the line with REV = needs to be set again to the original state, since it gather the state from standard ...
Title: Re: Extended client reports Standard revision number
Post by: jamespetts on December 14, 2020, 10:26:56 PM
Thank you both - I have now reverted this.