feat: show full commit version hash in sentry logs
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluralKit.Core
|
||||
@@ -7,18 +6,26 @@ namespace PluralKit.Core
|
||||
public static class BuildInfoService
|
||||
{
|
||||
public static string Version { get; private set; }
|
||||
public static string FullVersion { get; private set; }
|
||||
|
||||
public static async Task LoadVersion()
|
||||
{
|
||||
using (var stream = typeof(BuildInfoService).Assembly.GetManifestResourceStream("version"))
|
||||
{
|
||||
// if this happens, something broke
|
||||
if (stream == null) Version = "(unknown version) ";
|
||||
else using (var reader = new StreamReader(stream)) Version = await reader.ReadToEndAsync();
|
||||
if (stream == null) FullVersion = "(unknown version) ";
|
||||
else using (var reader = new StreamReader(stream)) FullVersion = await reader.ReadToEndAsync();
|
||||
}
|
||||
|
||||
// cheap hack to remove newline
|
||||
Version = Version.Remove(Version.Length - 1);
|
||||
FullVersion = FullVersion.Remove(FullVersion.Length - 1);
|
||||
|
||||
// show only short commit hash to users
|
||||
Version = FullVersion.Remove(7);
|
||||
|
||||
// fix "dirty" git message
|
||||
if (FullVersion.EndsWith("-dirty"))
|
||||
Version += "-dirty";
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user