25 lines
968 B
C#
25 lines
968 B
C#
using System.Reflection;
|
|
|
|
namespace Helpdesk.Web.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// Verze běžící webové aplikace z <c><Version></c> v projektu. SDK k ní při sestavení
|
|
/// v Gitu přidá hash commitu (<c>0.2.0+6e742b4…</c>); zobrazujeme jeho prvních 7 znaků,
|
|
/// aby při ladění bylo jasné, který commit běží.
|
|
/// </summary>
|
|
public static class AppVersion
|
|
{
|
|
public static string Display { get; } = Format(
|
|
typeof(AppVersion).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion);
|
|
|
|
internal static string Format(string? informationalVersion)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(informationalVersion))
|
|
return "neznámá";
|
|
|
|
var parts = informationalVersion.Split('+', 2);
|
|
var commit = parts.Length == 2 ? parts[1].Split('.')[0] : null;
|
|
return string.IsNullOrEmpty(commit) ? parts[0] : $"{parts[0]} ({commit[..Math.Min(7, commit.Length)]})";
|
|
}
|
|
}
|