2021-11-27 02:10:56 +00:00
|
|
|
namespace PluralKit.Core;
|
2021-08-01 19:22:23 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public static class BuildInfoService
|
2021-08-01 19:22:23 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
public static string Version { get; private set; }
|
|
|
|
public static string FullVersion { get; private set; }
|
2021-08-01 19:22:23 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public static async Task LoadVersion()
|
|
|
|
{
|
|
|
|
using (var stream = typeof(BuildInfoService).Assembly.GetManifestResourceStream("version"))
|
2021-08-01 19:22:23 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00: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 19:22:23 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
// cheap hack to remove newline
|
|
|
|
FullVersion = FullVersion.Remove(FullVersion.Length - 1);
|
2021-11-07 08:09:45 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
// show only short commit hash to users
|
|
|
|
Version = FullVersion.Remove(7);
|
2021-08-01 19:22:23 +00:00
|
|
|
}
|
|
|
|
}
|