Add VersionInfoPage

This commit is contained in:
jvyden 2022-01-16 21:14:14 -05:00
commit 75d4c25f59
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
5 changed files with 52 additions and 0 deletions

1
.gitignore vendored
View file

@ -21,6 +21,7 @@ riderModule.iml
lighthouse.config.json
gitBranch.txt
gitVersion.txt
gitRemotes.txt
ProjectLighthouse/.vscode/tasks.json
ProjectLighthouse/.vscode/launch.json
logs/Startup.log

View file

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using Kettu;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Types.Settings;
@ -14,6 +15,17 @@ namespace LBPUnion.ProjectLighthouse.Helpers
{
CommitHash = readManifestFile("gitVersion.txt");
Branch = readManifestFile("gitBranch.txt");
string remotesFile = readManifestFile("gitRemotes.txt");
string[] lines = remotesFile.Split('\n');
// line[0] line[1] line[2]
// origin git@github.com:LBPUnion/project-lighthouse.git (fetch)
// linq is a serious and painful catastrophe but its useful so i'm gonna keep using it
Remotes = lines.Select(line => line.Split("\t")[1]).ToArray();
CanCheckForUpdates = true;
}
catch
@ -54,6 +66,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
public static string FullVersion => $"{ServerStatics.ServerName} {Branch}@{CommitHash} {Build}";
public static bool IsDirty => CommitHash.EndsWith("-dirty");
public static bool CanCheckForUpdates { get; set; }
public static string[] Remotes { get; set; }
public const string Build =
#if DEBUG

View file

@ -0,0 +1,24 @@
@page "/debug/version"
@using LBPUnion.ProjectLighthouse.Helpers
@model LBPUnion.ProjectLighthouse.Pages.Debug.VersionInfoPage
@{
Layout = "Layouts/BaseLayout";
Model.Title = "Debug - Version Information";
Model.Description = VersionHelper.FullVersion;
}
<h2>Build specific information</h2>
<p><b>FullVersion</b>: @VersionHelper.FullVersion</p>
<br>
<p><b>Branch</b>: @VersionHelper.Branch</p>
<p><b>Build</b>: @VersionHelper.Build</p>
<p><b>CommitHash</b>: @VersionHelper.CommitHash</p>
<p><b>IsDirty</b>: @VersionHelper.IsDirty</p>
<p><b>CanCheckForUpdates</b>: @VersionHelper.CanCheckForUpdates</p>
<h2>Remotes</h2>
@foreach (string remote in VersionHelper.Remotes)
{
<p>@remote</p>
}

View file

@ -0,0 +1,12 @@
using JetBrains.Annotations;
using LBPUnion.ProjectLighthouse.Pages.Layouts;
using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Pages.Debug;
public class VersionInfoPage : BaseLayout
{
public VersionInfoPage([NotNull] Database database) : base(database)
{}
public IActionResult OnGet() => this.Page();
}

View file

@ -31,11 +31,13 @@
<EmbeddedResource Include="gitBranch.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<None Remove="gitRemotes.txt"/>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="git describe --long --always --dirty --exclude=\* --abbrev=8 &gt; &quot;$(ProjectDir)/gitVersion.txt&quot;"/>
<Exec Command="git branch --show-current &gt; &quot;$(ProjectDir)/gitBranch.txt&quot;"/>
<Exec Command="git remote -v &gt; &quot;$(ProjectDir)/gitRemotes.txt&quot;"/>
</Target>
</Project>