feat: add git commit count to assembly info/show in dev bar

This commit is contained in:
goat 2023-03-19 17:08:42 +01:00
parent d7c6172817
commit c8a7c69ee0
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
3 changed files with 39 additions and 3 deletions

View file

@ -28,6 +28,7 @@ namespace Dalamud.Utility;
public static class Util
{
private static string? gitHashInternal;
private static int? gitCommitCountInternal;
private static string? gitHashClientStructsInternal;
private static ulong moduleStartAddr;
@ -114,6 +115,26 @@ public static class Util
return gitHashInternal;
}
/// <summary>
/// Gets the amount of commits in the current branch, or null if undetermined.
/// </summary>
/// <returns>The amount of commits in the current branch.</returns>
public static int? GetGitCommitCount()
{
if (gitCommitCountInternal != null)
return gitCommitCountInternal.Value;
var asm = typeof(Util).Assembly;
var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
var value = attrs.First(a => a.Key == "GitCommitCount").Value;
if (value == null)
return null;
gitCommitCountInternal = int.Parse(value);
return gitCommitCountInternal.Value;
}
/// <summary>
/// Gets the git hash value from the assembly
/// or null if it cannot be found.