Enable the console show version command and the viewer about command, to show the last git commit hash together with the conmit date and time. The data is retrieved form a file bin/.version This file can be generated automatically using the post commit script by adding the following to the script:

git log -n 1 --pretty="format:%h: %ci" > bin/.version

This command can also be run manually to create the bin/.version file.

This command genrates a short form of the commit hash and a date and time of the commit in ISO8601 format.
If a full commit hash is required then change %h to %H

The logic that is used to extract the deprecated svn revision is still included.
It will be removed at a future date
arthursv
Chris Down 2009-08-10 15:14:29 +01:00 committed by Justin Clark-Casey (justincc)
parent 39c9f681ab
commit bb64906a9c
2 changed files with 50 additions and 25 deletions

1
.gitignore vendored
View File

@ -43,3 +43,4 @@ OpenSim/OpenSim.usertasks
TAGS TAGS
*~ *~
Makefile.local Makefile.local
bin/.version

View File

@ -76,7 +76,7 @@ namespace OpenSim.Framework.Servers
protected string m_startupDirectory = Environment.CurrentDirectory; protected string m_startupDirectory = Environment.CurrentDirectory;
/// <summary> /// <summary>
/// Server version information. Usually VersionInfo + information about svn revision, operating system, etc. /// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
/// </summary> /// </summary>
protected string m_version; protected string m_version;
@ -422,6 +422,16 @@ namespace OpenSim.Framework.Servers
{ {
string buildVersion = string.Empty; string buildVersion = string.Empty;
// Add commit hash and date information if available
// The commit hash and date are stored in a file bin/.version
// This file can automatically created by a post
// commit script in the opensim git master repository or
// by issuing the follwoing command from the top level
// directory of the opensim repository
// git log -n 1 --pretty="format:%h: %ci" >bin/.version
// For the full git commit hash use %H instead of %h
//
// The subversion information is deprecated and will be removed at a later date
// Add subversion revision information if available // Add subversion revision information if available
// Try file "svn_revision" in the current directory first, then the .svn info. // Try file "svn_revision" in the current directory first, then the .svn info.
// This allows to make the revision available in simulators not running from the source tree. // This allows to make the revision available in simulators not running from the source tree.
@ -429,39 +439,53 @@ namespace OpenSim.Framework.Servers
// elsewhere as well // elsewhere as well
string svnRevisionFileName = "svn_revision"; string svnRevisionFileName = "svn_revision";
string svnFileName = ".svn/entries"; string svnFileName = ".svn/entries";
string gitCommitFileName = ".version";
string inputLine; string inputLine;
int strcmp; int strcmp;
if (File.Exists(svnRevisionFileName)) if (File.Exists( gitCommitFileName))
{ {
StreamReader RevisionFile = File.OpenText(svnRevisionFileName); StreamReader CommitFile = File.OpenText(gitCommitFileName);
buildVersion = RevisionFile.ReadLine(); buildVersion = Environment.NewLine + "git# " + CommitFile.ReadLine();
buildVersion.Trim(); CommitFile.Close();
RevisionFile.Close(); m_version += buildVersion ?? "";
} }
if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName)) // Remove the else logic when subversion mirror is no longer used
else
{ {
StreamReader EntriesFile = File.OpenText(svnFileName); if (File.Exists(svnRevisionFileName))
inputLine = EntriesFile.ReadLine();
while (inputLine != null)
{ {
// using the dir svn revision at the top of entries file StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
strcmp = String.Compare(inputLine, "dir"); buildVersion = RevisionFile.ReadLine();
if (strcmp == 0) buildVersion.Trim();
{ RevisionFile.Close();
buildVersion = EntriesFile.ReadLine();
break;
}
else
{
inputLine = EntriesFile.ReadLine();
}
}
EntriesFile.Close();
}
m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); }
if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
{
StreamReader EntriesFile = File.OpenText(svnFileName);
inputLine = EntriesFile.ReadLine();
while (inputLine != null)
{
// using the dir svn revision at the top of entries file
strcmp = String.Compare(inputLine, "dir");
if (strcmp == 0)
{
buildVersion = EntriesFile.ReadLine();
break;
}
else
{
inputLine = EntriesFile.ReadLine();
}
}
EntriesFile.Close();
}
m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
}
} }
protected void CreatePIDFile(string path) protected void CreatePIDFile(string path)