mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-03-30 22:57:06 +00:00
Build.UpdateVersion can track the git revision now, in addition to svn and bzr.
This commit is contained in:
parent
339ffa61db
commit
0847b2ca5c
|
@ -88,9 +88,12 @@ namespace Build.UpdateVersion
|
|||
double timespan = now.Subtract(new DateTime(2010, 1, 1)).TotalDays;
|
||||
string build = ((int)timespan).ToString();
|
||||
|
||||
string revision = RetrieveSvnRevision() ?? RetrieveBzrRevision() ?? RetrieveSeconds(timespan);
|
||||
string revision = RetrieveGitRevision() ?? RetrieveSvnRevision() ?? RetrieveBzrRevision() ?? RetrieveSeconds(timespan);
|
||||
revision = revision.Trim();
|
||||
|
||||
Console.WriteLine("Build timestamp was: " + build);
|
||||
Console.WriteLine("Revision detected was: " + revision);
|
||||
|
||||
File.WriteAllLines(file, new string[]
|
||||
{
|
||||
"// This file is auto-generated through Source/Build.Tasks/GenerateAssemblyInfo.cs.",
|
||||
|
@ -117,6 +120,26 @@ namespace Build.UpdateVersion
|
|||
return revision;
|
||||
}
|
||||
|
||||
static string RetrieveGitRevision()
|
||||
{
|
||||
try
|
||||
{
|
||||
string output = RunProcess("git", "log -1", RootDirectory);
|
||||
|
||||
const string RevisionText = "commit ";
|
||||
int index = output.IndexOf(RevisionText);
|
||||
int endIndex = output.IndexOf("\n"); // since it's the first line...
|
||||
if (index > -1)
|
||||
return output.Substring(index + RevisionText.Length, endIndex - index - RevisionText.Length).Trim();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Print("Failed to retrieve git revision. Error: {0}", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static string RetrieveSvnRevision()
|
||||
{
|
||||
try
|
||||
|
|
|
@ -42,6 +42,11 @@ namespace Examples
|
|||
{
|
||||
try
|
||||
{
|
||||
// This seems to be useful enough to leave in for a while.
|
||||
TextWriterTraceListener console = new TextWriterTraceListener(System.Console.Out);
|
||||
Trace.Listeners.Add (console);
|
||||
Debug.Listeners.Add (console);
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue