2021-11-26 21:10:56 -05:00
|
|
|
namespace PluralKit.Core;
|
2021-08-01 15:22:23 -04:00
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
public static class BuildInfoService
|
2021-08-01 15:22:23 -04:00
|
|
|
{
|
2021-11-26 21:10:56 -05:00
|
|
|
public static string Version { get; private set; }
|
|
|
|
public static string FullVersion { get; private set; }
|
2021-08-01 15:22:23 -04:00
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
public static async Task LoadVersion()
|
|
|
|
{
|
|
|
|
using (var stream = typeof(BuildInfoService).Assembly.GetManifestResourceStream("version"))
|
2021-08-01 15:22:23 -04:00
|
|
|
{
|
2021-11-26 21:10:56 -05:00
|
|
|
// if this happens, something broke
|
|
|
|
if (stream == null) FullVersion = "(unknown version) ";
|
|
|
|
else
|
|
|
|
using (var reader = new StreamReader(stream))
|
|
|
|
FullVersion = await reader.ReadToEndAsync();
|
|
|
|
}
|
2021-08-01 15:22:23 -04:00
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
// cheap hack to remove newline
|
|
|
|
FullVersion = FullVersion.Remove(FullVersion.Length - 1);
|
2021-11-07 03:09:45 -05:00
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
// show only short commit hash to users
|
|
|
|
Version = FullVersion.Remove(7);
|
2021-08-01 15:22:23 -04:00
|
|
|
}
|
|
|
|
}
|