mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-21 11:20:58 +00:00
Internal: Git commit hash is how shown in the About window.
Internal: Git commit hashes are now shown in the Update window changelog. Internal: Exception window now links to GitHub Issue Tracker instead of zdoom.org GZDB thread.
This commit is contained in:
parent
9f4e700c56
commit
be1e799688
12 changed files with 135 additions and 79 deletions
|
@ -743,6 +743,7 @@
|
|||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Data\Scripting\ScriptResource.cs" />
|
||||
<Compile Include="General\AssemblyHash.cs" />
|
||||
<Compile Include="Rendering\RenderModeEnums.cs" />
|
||||
<Compile Include="Config\PasteOptions.cs" />
|
||||
<Compile Include="Config\ScriptDocumentSettings.cs" />
|
||||
|
@ -1342,7 +1343,6 @@
|
|||
<None Include="Resources\Test.png" />
|
||||
<None Include="Resources\Warning.png" />
|
||||
<None Include="Resources\WarningOff.png" />
|
||||
<None Include="Resources\SlimDX_small.png" />
|
||||
<None Include="Resources\Splash3_trans.png" />
|
||||
<None Include="Resources\Splash3_small.png" />
|
||||
<EmbeddedResource Include="Resources\UDMF.cfg" />
|
||||
|
|
17
Source/Core/General/AssemblyHash.cs
Normal file
17
Source/Core/General/AssemblyHash.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
|
||||
//mxd. Attribute to store git short hash string
|
||||
namespace CodeImp.DoomBuilder
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
|
||||
public class AssemblyHashAttribute : Attribute
|
||||
{
|
||||
private String commithash;
|
||||
public String CommitHash { get { return commithash; } }
|
||||
|
||||
public AssemblyHashAttribute(String commithash)
|
||||
{
|
||||
this.commithash = commithash;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -164,6 +164,7 @@ namespace CodeImp.DoomBuilder
|
|||
private static ColorCollection colors;
|
||||
private static TypesManager types;
|
||||
private static ErrorLogger errorlogger;
|
||||
private static string commithash; //mxd. Git commit hash
|
||||
//private static Mutex appmutex;
|
||||
|
||||
// Configurations
|
||||
|
@ -232,6 +233,7 @@ namespace CodeImp.DoomBuilder
|
|||
public static bool NoSettings { get { return nosettings; } }
|
||||
public static EditingManager Editing { get { return editing; } }
|
||||
public static ErrorLogger ErrorLogger { get { return errorlogger; } }
|
||||
public static string CommitHash { get { return commithash; } } //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -555,8 +557,6 @@ namespace CodeImp.DoomBuilder
|
|||
thisasm = Assembly.GetExecutingAssembly();
|
||||
|
||||
// Find application path
|
||||
//Uri localpath = new Uri(Path.GetDirectoryName(thisasm.GetName().CodeBase));
|
||||
//apppath = Uri.UnescapeDataString(localpath.AbsolutePath);
|
||||
apppath = Path.GetDirectoryName(Application.ExecutablePath); //mxd. What was the point of using Uri here (other than to prevent lauching from a shared folder)?
|
||||
|
||||
// Parse command-line arguments
|
||||
|
@ -578,10 +578,22 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Make program settings directory if missing
|
||||
if(!portablemode && !Directory.Exists(settingspath)) Directory.CreateDirectory(settingspath);
|
||||
|
||||
//mxd. Get git commit hash
|
||||
var hashes = (AssemblyHashAttribute[])thisasm.GetCustomAttributes(typeof(AssemblyHashAttribute), false);
|
||||
if(hashes.Length == 1)
|
||||
{
|
||||
commithash = hashes[0].CommitHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLogLine("Unable to determine commit hash. Missing AssemblyHashAttribute?");
|
||||
commithash = "0000000";
|
||||
}
|
||||
|
||||
// Remove the previous log file and start logging
|
||||
if(File.Exists(logfile)) File.Delete(logfile);
|
||||
General.WriteLogLine("GZDoom Builder R" + thisasm.GetName().Version.Revision + " startup"); //mxd
|
||||
General.WriteLogLine("GZDoom Builder R" + thisasm.GetName().Version.Revision + " (" + commithash + ") startup"); //mxd
|
||||
General.WriteLogLine("Application path: \"" + apppath + "\"");
|
||||
General.WriteLogLine("Temporary path: \"" + temppath + "\"");
|
||||
General.WriteLogLine("Local settings path: \"" + settingspath + "\"");
|
||||
|
|
|
@ -268,21 +268,28 @@ namespace CodeImp.DoomBuilder
|
|||
if(log.ChildNodes.Count == 0) continue;
|
||||
foreach(XmlNode logentry in log.ChildNodes)
|
||||
{
|
||||
if(logentry.Attributes == null) continue;
|
||||
var revnode = logentry.Attributes.GetNamedItem("revision");
|
||||
var comnode = logentry.Attributes.GetNamedItem("commit");
|
||||
if(revnode == null || comnode == null) continue;
|
||||
|
||||
int noderev;
|
||||
if(logentry.Attributes == null || !int.TryParse(logentry.Attributes.GetNamedItem("revision").Value, out noderev)) continue;
|
||||
if(!int.TryParse(revnode.Value, out noderev)) continue;
|
||||
if(noderev <= localrev) break;
|
||||
|
||||
// Add info
|
||||
sb.Append(@"{\b R" + noderev + @":}\par ");
|
||||
string commit = comnode.Value;
|
||||
string message = string.Empty;
|
||||
XmlNode msgnode = logentry["msg"];
|
||||
if(msgnode != null) message = msgnode.InnerText.Trim().Replace(Environment.NewLine, @"\par ");
|
||||
|
||||
foreach(XmlNode prop in logentry.ChildNodes)
|
||||
{
|
||||
if(prop.Name == "msg")
|
||||
{
|
||||
sb.Append(prop.InnerText.Trim().Replace(Environment.NewLine, @"\par ")).Append(@"\par\par ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Add info
|
||||
sb.Append(@"{\b R")
|
||||
.Append(noderev)
|
||||
.Append(" | ")
|
||||
.Append(commit)
|
||||
.Append(@":}\par ")
|
||||
.Append(message)
|
||||
.Append(@"\par\par ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Resources;
|
||||
using CodeImp.DoomBuilder;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
|
@ -31,3 +32,4 @@ using System.Resources;
|
|||
//
|
||||
[assembly: AssemblyVersion("2.3.0.2651")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||
[assembly: AssemblyHash("0000000")]
|
||||
|
|
7
Source/Core/Properties/Resources.Designer.cs
generated
7
Source/Core/Properties/Resources.Designer.cs
generated
|
@ -963,13 +963,6 @@ namespace CodeImp.DoomBuilder.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap SlimDX_small {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("SlimDX_small", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap SnapVerts {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("SnapVerts", resourceCulture);
|
||||
|
|
|
@ -514,9 +514,6 @@
|
|||
<data name="CommentProblem" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\CommentProblem.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="SlimDX_small" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\SlimDX_small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="KnownTextureSet" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\KnownTextureSet.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -36,7 +37,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
#if DEBUG
|
||||
version.Text = Application.ProductName + " [DEVBUILD]";
|
||||
#else
|
||||
version.Text = Application.ProductName + " v" + Application.ProductVersion;
|
||||
version.Text = Application.ProductName + " v" + Application.ProductVersion + " (" + General.CommitHash + ")";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -69,7 +70,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
try //mxd
|
||||
{
|
||||
Clipboard.SetDataObject(Application.ProductVersion, true, 5, 200);
|
||||
Clipboard.SetDataObject(Application.ProductVersion + " (" + General.CommitHash + ")", true, 5, 200);
|
||||
}
|
||||
catch(ExternalException)
|
||||
{
|
||||
|
|
|
@ -193,25 +193,19 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
return message;
|
||||
}
|
||||
|
||||
private void reportLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
private void reportlink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
if(!File.Exists(logpath)) return;
|
||||
System.Diagnostics.Process.Start("explorer.exe", @"/select, " + logpath);
|
||||
reportLink.LinkVisited = true;
|
||||
try { System.Diagnostics.Process.Start("explorer.exe", @"/select, " + logpath); }
|
||||
catch { MessageBox.Show("Unable to show the error report location..."); }
|
||||
reportlink.LinkVisited = true;
|
||||
}
|
||||
|
||||
private void threadLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
private void newissue_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process.Start("http://forum.zdoom.org/viewtopic.php?f=3&t=32392&start=9999999");
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
MessageBox.Show("Unable to open URL...");
|
||||
}
|
||||
|
||||
threadLink.LinkVisited = true;
|
||||
try { System.Diagnostics.Process.Start("https://github.com/m-x-d/GZDoom-Builder/issues"); }
|
||||
catch { MessageBox.Show("Unable to open URL..."); }
|
||||
newissue.LinkVisited = true;
|
||||
}
|
||||
|
||||
private void bContinue_Click(object sender, EventArgs e)
|
||||
|
|
64
Source/Core/Windows/ExceptionDialog.designer.cs
generated
64
Source/Core/Windows/ExceptionDialog.designer.cs
generated
|
@ -32,8 +32,8 @@
|
|||
this.bContinue = new System.Windows.Forms.Button();
|
||||
this.errorMessage = new System.Windows.Forms.TextBox();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.reportLink = new System.Windows.Forms.LinkLabel();
|
||||
this.threadLink = new System.Windows.Forms.LinkLabel();
|
||||
this.reportlink = new System.Windows.Forms.LinkLabel();
|
||||
this.newissue = new System.Windows.Forms.LinkLabel();
|
||||
this.bToClipboard = new System.Windows.Forms.Button();
|
||||
this.errorDescription = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
|
@ -59,7 +59,7 @@
|
|||
this.bContinue.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.bContinue.Location = new System.Drawing.Point(446, 212);
|
||||
this.bContinue.Name = "bContinue";
|
||||
this.bContinue.Size = new System.Drawing.Size(85, 28);
|
||||
this.bContinue.Size = new System.Drawing.Size(88, 28);
|
||||
this.bContinue.TabIndex = 1;
|
||||
this.bContinue.Text = "Continue";
|
||||
this.bContinue.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
|
@ -85,34 +85,34 @@
|
|||
this.pictureBox1.TabIndex = 2;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// reportLink
|
||||
// reportlink
|
||||
//
|
||||
this.reportLink.AutoSize = true;
|
||||
this.reportLink.LinkArea = new System.Windows.Forms.LinkArea(53, 4);
|
||||
this.reportLink.LinkColor = System.Drawing.SystemColors.HotTrack;
|
||||
this.reportLink.Location = new System.Drawing.Point(77, 188);
|
||||
this.reportLink.Name = "reportLink";
|
||||
this.reportLink.Size = new System.Drawing.Size(286, 17);
|
||||
this.reportLink.TabIndex = 5;
|
||||
this.reportLink.TabStop = true;
|
||||
this.reportLink.Text = "Error report with additional information was created here";
|
||||
this.reportLink.UseCompatibleTextRendering = true;
|
||||
this.reportLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.reportLink_LinkClicked);
|
||||
this.reportlink.AutoSize = true;
|
||||
this.reportlink.LinkArea = new System.Windows.Forms.LinkArea(101, 16);
|
||||
this.reportlink.LinkColor = System.Drawing.SystemColors.HotTrack;
|
||||
this.reportlink.Location = new System.Drawing.Point(75, 211);
|
||||
this.reportlink.Name = "reportlink";
|
||||
this.reportlink.Size = new System.Drawing.Size(369, 30);
|
||||
this.reportlink.TabIndex = 5;
|
||||
this.reportlink.TabStop = true;
|
||||
this.reportlink.Text = "Including the steps required to reproduce this error, a test map/resource\r\nrequre" +
|
||||
"d to trigger it and the error report can immensely help fixing it.";
|
||||
this.reportlink.UseCompatibleTextRendering = true;
|
||||
this.reportlink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.reportlink_LinkClicked);
|
||||
//
|
||||
// threadLink
|
||||
// gitissueslink
|
||||
//
|
||||
this.threadLink.AutoSize = true;
|
||||
this.threadLink.LinkArea = new System.Windows.Forms.LinkArea(101, 28);
|
||||
this.threadLink.LinkColor = System.Drawing.SystemColors.HotTrack;
|
||||
this.threadLink.Location = new System.Drawing.Point(77, 210);
|
||||
this.threadLink.Name = "threadLink";
|
||||
this.threadLink.Size = new System.Drawing.Size(349, 30);
|
||||
this.threadLink.TabIndex = 8;
|
||||
this.threadLink.TabStop = true;
|
||||
this.threadLink.Text = "You can help fixing this error if you provide the ways to reproduce it \r\nand the " +
|
||||
"error report at the official thread at ZDoom.org";
|
||||
this.threadLink.UseCompatibleTextRendering = true;
|
||||
this.threadLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.threadLink_LinkClicked);
|
||||
this.newissue.AutoSize = true;
|
||||
this.newissue.LinkArea = new System.Windows.Forms.LinkArea(51, 21);
|
||||
this.newissue.LinkColor = System.Drawing.SystemColors.HotTrack;
|
||||
this.newissue.Location = new System.Drawing.Point(75, 188);
|
||||
this.newissue.Name = "newissue";
|
||||
this.newissue.Size = new System.Drawing.Size(359, 17);
|
||||
this.newissue.TabIndex = 8;
|
||||
this.newissue.TabStop = true;
|
||||
this.newissue.Text = "Help fixing this error by creating an Issue at the GitHub Issues Tracker.";
|
||||
this.newissue.UseCompatibleTextRendering = true;
|
||||
this.newissue.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.newissue_LinkClicked);
|
||||
//
|
||||
// bToClipboard
|
||||
//
|
||||
|
@ -144,10 +144,10 @@
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.CancelButton = this.bQuit;
|
||||
this.ClientSize = new System.Drawing.Size(624, 244);
|
||||
this.Controls.Add(this.reportLink);
|
||||
this.Controls.Add(this.reportlink);
|
||||
this.Controls.Add(this.errorDescription);
|
||||
this.Controls.Add(this.bToClipboard);
|
||||
this.Controls.Add(this.threadLink);
|
||||
this.Controls.Add(this.newissue);
|
||||
this.Controls.Add(this.errorMessage);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.bContinue);
|
||||
|
@ -173,8 +173,8 @@
|
|||
private System.Windows.Forms.Button bContinue;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.TextBox errorMessage;
|
||||
private System.Windows.Forms.LinkLabel reportLink;
|
||||
private System.Windows.Forms.LinkLabel threadLink;
|
||||
private System.Windows.Forms.LinkLabel reportlink;
|
||||
private System.Windows.Forms.LinkLabel newissue;
|
||||
private System.Windows.Forms.Button bToClipboard;
|
||||
private System.Windows.Forms.Label errorDescription;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace mxd.VersionFromGIT
|
|||
{
|
||||
#region ======================== Constants
|
||||
|
||||
private const string GIT_INFO = "@echo off\r\ngit rev-list --count master";
|
||||
private const string GIT_INFO = "@echo off\r\ngit rev-list --count master\r\ngit rev-parse --short master";
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -28,6 +28,7 @@ namespace mxd.VersionFromGIT
|
|||
bool dorevisionlookup = true;
|
||||
bool reverttargets = false;
|
||||
string revision = "";
|
||||
string shorthash = "";
|
||||
string apppath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
string revisionoutputfile = "";
|
||||
|
||||
|
@ -102,12 +103,28 @@ namespace mxd.VersionFromGIT
|
|||
p.Start();
|
||||
|
||||
// Read the output stream first and then wait.
|
||||
revision = p.StandardOutput.ReadToEnd().Trim();
|
||||
string output = p.StandardOutput.ReadToEnd().Trim(); //mxd. first line is revision, second - short hash
|
||||
p.WaitForExit();
|
||||
File.Delete(batpath);
|
||||
|
||||
//mxd. Check what we've got
|
||||
string[] parts = output.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if(parts.Length != 2)
|
||||
{
|
||||
Console.WriteLine("Unable to get Git info from string \"" + output + "\". You must install Git from https://git-scm.com");
|
||||
return 3;
|
||||
}
|
||||
|
||||
//mxd. Check hash
|
||||
shorthash = parts[1];
|
||||
if(shorthash.Length != 7)
|
||||
{
|
||||
Console.WriteLine("Unable to get Git hash from string \"" + shorthash + "\". You must install Git from https://git-scm.com");
|
||||
return 4;
|
||||
}
|
||||
|
||||
//mxd. Check revision
|
||||
int unused;
|
||||
revision = parts[0];
|
||||
if(string.IsNullOrEmpty(revision) || !int.TryParse(revision, out unused) || unused < 1)
|
||||
{
|
||||
Console.WriteLine("Unable to get Git commits count from string \"" + revision + "\". You must install Git from https://git-scm.com");
|
||||
|
@ -116,7 +133,7 @@ namespace mxd.VersionFromGIT
|
|||
}
|
||||
|
||||
if(!string.IsNullOrEmpty(revisionoutputfile))
|
||||
File.AppendAllText(revisionoutputfile, "SET REVISIONNUMBER=" + revision + "\n");
|
||||
File.AppendAllText(revisionoutputfile, "SET REVISIONNUMBER=" + revision + "\nSET REVISIONHASH=" + shorthash);
|
||||
|
||||
if(reverttargets)
|
||||
{
|
||||
|
@ -144,7 +161,7 @@ namespace mxd.VersionFromGIT
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Writing revision " + revision + " to target files...");
|
||||
Console.WriteLine("Writing revision " + revision + ", hash " + shorthash + " to target files...");
|
||||
foreach(string file in targetfiles)
|
||||
{
|
||||
bool changed = false;
|
||||
|
@ -163,6 +180,22 @@ namespace mxd.VersionFromGIT
|
|||
string lineend = line.Substring(endbracepos);
|
||||
string result = linestart + revision + lineend;
|
||||
|
||||
if(string.Compare(contents[i], result, true) != 0)
|
||||
{
|
||||
contents[i] = result;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
//mxd. Apply hash
|
||||
else if(line.Trim().StartsWith("[assembly: AssemblyHash", true, CultureInfo.InvariantCulture))
|
||||
{
|
||||
int startbracepos = line.IndexOf("\"", 0);
|
||||
int endbracepos = line.IndexOf("\"", startbracepos + 1);
|
||||
|
||||
string linestart = line.Substring(0, startbracepos + 1);
|
||||
string lineend = line.Substring(endbracepos);
|
||||
string result = linestart + shorthash + lineend;
|
||||
|
||||
if(string.Compare(contents[i], result, true) != 0)
|
||||
{
|
||||
contents[i] = result;
|
||||
|
@ -202,7 +235,7 @@ namespace mxd.VersionFromGIT
|
|||
Console.WriteLine("This will revert all changes in the specified target files (same as GIT checkout function). This will not apply commits count to the target files.\r\n");
|
||||
|
||||
Console.WriteLine("-O filename");
|
||||
Console.WriteLine("Creates a bath file, which sets REVISIONNUMBER environment variable to the GIT revision number.\r\n");
|
||||
Console.WriteLine("Creates a bath file, which sets REVISIONNUMBER environment variable to the GIT revision number and REVISIONHASH environment variable to the GIT revision short hash.\r\n");
|
||||
|
||||
Console.WriteLine("Press any key to quit.");
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue