mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 06:13:40 +01:00
feat: Use new versioning strategy
- Rename BuildHash to SCMVersion - Expose the actual commit hash as a new `commit_hash.txt` - Update GetGitHash() to actually return the git hash
This commit is contained in:
parent
0c1b2a03b2
commit
2b96f2187c
9 changed files with 67 additions and 61 deletions
|
|
@ -61,6 +61,7 @@ public static class Util
|
|||
];
|
||||
|
||||
private static readonly Type GenericSpanType = typeof(Span<>);
|
||||
private static string? scmVersionInternal;
|
||||
private static string? gitHashInternal;
|
||||
private static int? gitCommitCountInternal;
|
||||
private static string? gitHashClientStructsInternal;
|
||||
|
|
@ -127,11 +128,28 @@ public static class Util
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the git hash value from the assembly
|
||||
/// or null if it cannot be found.
|
||||
/// Gets the SCM Version from the assembly, or null if it cannot be found. This method will generally return
|
||||
/// the <c>git describe</c> output for this build, which will be a raw version if this is a stable build or an
|
||||
/// appropriately-annotated version if this is *not* stable. Local builds will return a `Local Build` text string.
|
||||
/// </summary>
|
||||
/// <returns>The SCM version of the assembly.</returns>
|
||||
public static string GetScmVersion()
|
||||
{
|
||||
if (scmVersionInternal != null) return scmVersionInternal;
|
||||
|
||||
var asm = typeof(Util).Assembly;
|
||||
var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
|
||||
|
||||
return scmVersionInternal = attrs.First(a => a.Key == "SCMVersion").Value
|
||||
?? asm.GetName().Version!.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the git commit hash value from the assembly or null if it cannot be found. Will be null for Debug builds,
|
||||
/// and will be suffixed with `-dirty` if in release with pending changes.
|
||||
/// </summary>
|
||||
/// <returns>The git hash of the assembly.</returns>
|
||||
public static string GetGitHash()
|
||||
public static string? GetGitHash()
|
||||
{
|
||||
if (gitHashInternal != null)
|
||||
return gitHashInternal;
|
||||
|
|
@ -139,15 +157,14 @@ public static class Util
|
|||
var asm = typeof(Util).Assembly;
|
||||
var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
|
||||
|
||||
gitHashInternal = attrs.First(a => a.Key == "GitHash").Value;
|
||||
|
||||
return gitHashInternal;
|
||||
return gitHashInternal = attrs.First(a => a.Key == "GitHash").Value;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
[Obsolete($"Planned for removal in API 11. Use {nameof(GetScmVersion)} for version tracking.")]
|
||||
public static int? GetGitCommitCount()
|
||||
{
|
||||
if (gitCommitCountInternal != null)
|
||||
|
|
@ -169,7 +186,7 @@ public static class Util
|
|||
/// or null if it cannot be found.
|
||||
/// </summary>
|
||||
/// <returns>The git hash of the assembly.</returns>
|
||||
public static string GetGitHashClientStructs()
|
||||
public static string? GetGitHashClientStructs()
|
||||
{
|
||||
if (gitHashClientStructsInternal != null)
|
||||
return gitHashClientStructsInternal;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue