From bb64906a9cc891d9cc439bd2eda6ebf726364ca0 Mon Sep 17 00:00:00 2001 From: Chris Down Date: Mon, 10 Aug 2009 15:14:29 +0100 Subject: 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 --- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 68 +++++++++++++++++--------- 1 file changed, 46 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/Servers/BaseOpenSimServer.cs') diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index d2193ca..2a97528 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -76,7 +76,7 @@ namespace OpenSim.Framework.Servers protected string m_startupDirectory = Environment.CurrentDirectory; /// - /// Server version information. Usually VersionInfo + information about svn revision, operating system, etc. + /// Server version information. Usually VersionInfo + information about git commit, operating system, etc. /// protected string m_version; @@ -422,6 +422,16 @@ namespace OpenSim.Framework.Servers { 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 // 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. @@ -429,39 +439,53 @@ namespace OpenSim.Framework.Servers // elsewhere as well string svnRevisionFileName = "svn_revision"; string svnFileName = ".svn/entries"; + string gitCommitFileName = ".version"; string inputLine; int strcmp; - if (File.Exists(svnRevisionFileName)) + if (File.Exists( gitCommitFileName)) { - StreamReader RevisionFile = File.OpenText(svnRevisionFileName); - buildVersion = RevisionFile.ReadLine(); - buildVersion.Trim(); - RevisionFile.Close(); + StreamReader CommitFile = File.OpenText(gitCommitFileName); + buildVersion = Environment.NewLine + "git# " + CommitFile.ReadLine(); + CommitFile.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); - inputLine = EntriesFile.ReadLine(); - while (inputLine != null) + if (File.Exists(svnRevisionFileName)) { - // using the dir svn revision at the top of entries file - strcmp = String.Compare(inputLine, "dir"); - if (strcmp == 0) - { - buildVersion = EntriesFile.ReadLine(); - break; - } - else + StreamReader RevisionFile = File.OpenText(svnRevisionFileName); + buildVersion = RevisionFile.ReadLine(); + buildVersion.Trim(); + RevisionFile.Close(); + + } + + if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName)) + { + StreamReader EntriesFile = File.OpenText(svnFileName); + inputLine = EntriesFile.ReadLine(); + while (inputLine != null) { - inputLine = EntriesFile.ReadLine(); + // 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(); } - EntriesFile.Close(); - } - m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); + m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); + } } protected void CreatePIDFile(string path) -- cgit v1.1