diff options
author | Justin Clark-Casey (justincc) | 2011-07-01 22:48:00 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-07-01 22:48:00 +0100 |
commit | e765759f504b86a643fd8843e41b0283422f7980 (patch) | |
tree | cc22b529890e3ea12bd9eaac959d38e02ddb746e | |
parent | refactor: rename gitCommitFileName to manualVersionFileName since bin/.versio... (diff) | |
download | opensim-SC-e765759f504b86a643fd8843e41b0283422f7980.zip opensim-SC-e765759f504b86a643fd8843e41b0283422f7980.tar.gz opensim-SC-e765759f504b86a643fd8843e41b0283422f7980.tar.bz2 opensim-SC-e765759f504b86a643fd8843e41b0283422f7980.tar.xz |
If OpenSim has been built from a git tree, then include version information automatically by dereferencing .git/HEAD
A blank bin/.version file will stop this being displayed.
-rw-r--r-- | OpenSim/Framework/Servers/BaseOpenSimServer.cs | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 98a92dd..d4c3d08 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -31,6 +31,7 @@ using System.Diagnostics; | |||
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Text.RegularExpressions; | ||
34 | using System.Threading; | 35 | using System.Threading; |
35 | using System.Timers; | 36 | using System.Timers; |
36 | using log4net; | 37 | using log4net; |
@@ -124,7 +125,6 @@ namespace OpenSim.Framework.Servers | |||
124 | m_logFileAppender = appender; | 125 | m_logFileAppender = appender; |
125 | } | 126 | } |
126 | } | 127 | } |
127 | |||
128 | } | 128 | } |
129 | 129 | ||
130 | /// <summary> | 130 | /// <summary> |
@@ -458,6 +458,9 @@ namespace OpenSim.Framework.Servers | |||
458 | // This allows to make the revision available in simulators not running from the source tree. | 458 | // This allows to make the revision available in simulators not running from the source tree. |
459 | // FIXME: Making an assumption about the directory we're currently in - we do this all over the place | 459 | // FIXME: Making an assumption about the directory we're currently in - we do this all over the place |
460 | // elsewhere as well | 460 | // elsewhere as well |
461 | string gitDir = "../.git/"; | ||
462 | string gitRefPointerPath = gitDir + "HEAD"; | ||
463 | |||
461 | string svnRevisionFileName = "svn_revision"; | 464 | string svnRevisionFileName = "svn_revision"; |
462 | string svnFileName = ".svn/entries"; | 465 | string svnFileName = ".svn/entries"; |
463 | string manualVersionFileName = ".version"; | 466 | string manualVersionFileName = ".version"; |
@@ -466,13 +469,45 @@ namespace OpenSim.Framework.Servers | |||
466 | 469 | ||
467 | if (File.Exists(manualVersionFileName)) | 470 | if (File.Exists(manualVersionFileName)) |
468 | { | 471 | { |
469 | StreamReader CommitFile = File.OpenText(manualVersionFileName); | 472 | using (StreamReader CommitFile = File.OpenText(manualVersionFileName)) |
470 | buildVersion = CommitFile.ReadLine(); | 473 | buildVersion = CommitFile.ReadLine(); |
471 | CommitFile.Close(); | 474 | |
472 | m_version += buildVersion ?? ""; | 475 | m_version += buildVersion ?? ""; |
473 | } | 476 | } |
477 | else if (File.Exists(gitRefPointerPath)) | ||
478 | { | ||
479 | // m_log.DebugFormat("[OPENSIM]: Found {0}", gitRefPointerPath); | ||
480 | |||
481 | string rawPointer = ""; | ||
482 | |||
483 | using (StreamReader pointerFile = File.OpenText(gitRefPointerPath)) | ||
484 | rawPointer = pointerFile.ReadLine(); | ||
485 | |||
486 | // m_log.DebugFormat("[OPENSIM]: rawPointer [{0}]", rawPointer); | ||
487 | |||
488 | Match m = Regex.Match(rawPointer, "^ref: (.+)$"); | ||
489 | |||
490 | if (m.Success) | ||
491 | { | ||
492 | // m_log.DebugFormat("[OPENSIM]: Matched [{0}]", m.Groups[1].Value); | ||
493 | |||
494 | string gitRef = m.Groups[1].Value; | ||
495 | string gitRefPath = gitDir + gitRef; | ||
496 | if (File.Exists(gitRefPath)) | ||
497 | { | ||
498 | // m_log.DebugFormat("[OPENSIM]: Found gitRefPath [{0}]", gitRefPath); | ||
499 | |||
500 | using (StreamReader refFile = File.OpenText(gitRefPath)) | ||
501 | { | ||
502 | string gitHash = refFile.ReadLine(); | ||
503 | m_version += gitHash.Substring(0, 7); | ||
504 | } | ||
505 | } | ||
506 | } | ||
507 | } | ||
474 | else | 508 | else |
475 | { | 509 | { |
510 | m_log.DebugFormat("[OPENSIM]: Looking for SVN"); | ||
476 | // Remove the else logic when subversion mirror is no longer used | 511 | // Remove the else logic when subversion mirror is no longer used |
477 | if (File.Exists(svnRevisionFileName)) | 512 | if (File.Exists(svnRevisionFileName)) |
478 | { | 513 | { |