Improved version detecting

This commit is contained in:
Marcel Baumgartner
2024-06-30 01:51:20 +02:00
parent 48e84e815b
commit c6d88fe7bf
2 changed files with 24 additions and 28 deletions

View File

@@ -19,35 +19,31 @@ public class MoonlightService
public MoonlightService()
{
//TODO: Maybe extract to a method
//TODO: Maybe extract to a method to make this a bit cleaner
if (!File.Exists("version"))
{
BuildChannel = "N/A";
BuildCommitHash = "N/A";
BuildName = "N/A";
BuildVersion = "N/A";
IsDockerRun = false;
return;
}
if (File.Exists("version"))
{
var line = File.ReadAllText("version");
line = line.Trim();
var line = File.ReadAllText("version");
var parts = line.Split(";");
var parts = line.Split(";");
if (parts.Length < 5)
{
BuildChannel = "N/A";
BuildCommitHash = "N/A";
BuildName = "N/A";
BuildVersion = "N/A";
IsDockerRun = false;
}
if (parts.Length >= 5)
{
BuildChannel = parts[0];
BuildCommitHash = parts[1];
BuildName = parts[2];
BuildVersion = parts[3];
IsDockerRun = parts[4] == "docker";
return;
}
}
BuildChannel = parts[0];
BuildCommitHash = parts[1];
BuildName = parts[2];
BuildVersion = parts[3];
IsDockerRun = parts[4] == "docker";
BuildChannel = "N/A";
BuildCommitHash = "N/A";
BuildName = "N/A";
BuildVersion = "N/A";
IsDockerRun = false;
//TODO: Add log call
}

View File

@@ -48,7 +48,7 @@
</div>
<div class="col-md-3 col-12">
@{
var commitText = $"{MoonlightService.BuildCommitHash} (up-to-date)";
var commitText = $"{MoonlightService.BuildCommitHash}"; // TODO: Add update check (possible during startup, with error handling etc)
}
<StatCard Value="@commitText" Description="Commit" Icon="bxl-git"/>