-@foreach (string remote in VersionHelper.Remotes)
-{
-
@remote
-}
\ No newline at end of file
+
RepositoryUrl: @VersionHelper.RepositoryUrl
\ No newline at end of file
diff --git a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml
index 614abfa3..1f6ce65a 100644
--- a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml
@@ -200,7 +200,7 @@
@{
- string? remoteUrl = VersionHelper.DetermineRemoteUrl();
+ string? remoteUrl = VersionHelper.RepositoryUrl;
}
@Model.Translate(BaseLayoutStrings.GeneratedBy, VersionHelper.FullVersion)
diff --git a/ProjectLighthouse.Servers.Website/ProjectLighthouse.Servers.Website.csproj b/ProjectLighthouse.Servers.Website/ProjectLighthouse.Servers.Website.csproj
index 9b115057..50691b8b 100644
--- a/ProjectLighthouse.Servers.Website/ProjectLighthouse.Servers.Website.csproj
+++ b/ProjectLighthouse.Servers.Website/ProjectLighthouse.Servers.Website.csproj
@@ -13,34 +13,4 @@
-
-
-
-
- Always
-
-
-
- Always
-
-
-
- Always
-
-
-
- Always
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ProjectLighthouse.Servers.Website/Startup/WebsiteStartup.cs b/ProjectLighthouse.Servers.Website/Startup/WebsiteStartup.cs
index c391fc5e..bb89c6bf 100644
--- a/ProjectLighthouse.Servers.Website/Startup/WebsiteStartup.cs
+++ b/ProjectLighthouse.Servers.Website/Startup/WebsiteStartup.cs
@@ -37,18 +37,7 @@ public class WebsiteStartup
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
- #if DEBUG
- services.AddRazorPages().WithRazorPagesAtContentRoot().AddRazorRuntimeCompilation((options) =>
- {
- // jank but works
- string projectDir = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", ".."));
-
- options.FileProviders.Clear();
- options.FileProviders.Add(new PhysicalFileProvider(projectDir));
- });
- #else
services.AddRazorPages().WithRazorPagesAtContentRoot();
- #endif
services.AddDbContext(builder =>
{
diff --git a/ProjectLighthouse/Helpers/ResourceHelper.cs b/ProjectLighthouse/Helpers/ResourceHelper.cs
deleted file mode 100644
index fc9a1ee1..00000000
--- a/ProjectLighthouse/Helpers/ResourceHelper.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.IO;
-
-namespace LBPUnion.ProjectLighthouse.Helpers;
-
-public static class ResourceHelper
-{
- public static string ReadManifestFile(string fileName)
- {
- using Stream stream = typeof(StartupTasks).Assembly.GetManifestResourceStream($"{typeof(StartupTasks).Namespace}.{fileName}");
- using StreamReader reader = new(stream ?? throw new Exception("The assembly or manifest resource is null."));
-
- return reader.ReadToEnd().Trim();
- }
-}
\ No newline at end of file
diff --git a/ProjectLighthouse/Helpers/VersionHelper.cs b/ProjectLighthouse/Helpers/VersionHelper.cs
index ec4363ab..895c36f7 100644
--- a/ProjectLighthouse/Helpers/VersionHelper.cs
+++ b/ProjectLighthouse/Helpers/VersionHelper.cs
@@ -1,79 +1,17 @@
-using System.Linq;
-using System.Text.RegularExpressions;
using LBPUnion.ProjectLighthouse.Configuration;
-using LBPUnion.ProjectLighthouse.Logging;
-using LBPUnion.ProjectLighthouse.Types.Logging;
namespace LBPUnion.ProjectLighthouse.Helpers;
-public static partial class VersionHelper
+public static class VersionHelper
{
- static VersionHelper()
- {
- try
- {
- CommitHash = ResourceHelper.ReadManifestFile("gitVersion.txt");
- Branch = ResourceHelper.ReadManifestFile("gitBranch.txt");
- string commitNumber = $"{CommitHash}_{Build}";
- FullRevision = Branch == "main" ? $"r{commitNumber}" : $"{Branch}_r{commitNumber}";
+ public static string CommitHash => ThisAssembly.Git.Commit;
+ public static string Branch => ThisAssembly.Git.Branch;
- string remotesFile = ResourceHelper.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();
-
- CommitsOutOfDate = ResourceHelper.ReadManifestFile("gitUnpushed.txt").Split('\n').Length;
-
- CanCheckForUpdates = true;
- }
- catch
- {
- Logger.Error("Project Lighthouse was built incorrectly. Please make sure git is available when building.",
- LogArea.Startup);
- CommitHash = "invalid";
- Branch = "invalid";
- CanCheckForUpdates = false;
- }
-
- if (!IsDirty) return;
-
- Logger.Warn("This is a modified version of Project Lighthouse. " +
- "Please make sure you are properly disclosing the source code to any users who may be using this instance.",
- LogArea.Startup);
- CanCheckForUpdates = false;
- }
-
- [GeneratedRegex(@"((git|ssh|http(s)?)|(git@[\w\.-]+))(:(\/\/)?)([\w\.@\:\/\-~]+)((\.git)(\/))?( .+)?")]
- private static partial Regex GitRemoteRegex();
-
- #nullable enable
- ///
- /// Determines the URL of the git remote.
- ///
- public static string? DetermineRemoteUrl()
- {
- string? remote = Remotes?.FirstOrDefault();
- if (remote == null) return null;
-
- Match match = GitRemoteRegex().Match(remote);
-
- if (!match.Success || match.Groups.Count != 12) return null;
-
- return match.Groups[7].Value;
- }
- #nullable disable
-
- public static string CommitHash { get; set; }
- public static string Branch { get; set; }
///
/// The full revision string. States current revision hash and, if not main, the branch.
///
- private static string FullRevision { get; set; }
+ private static string FullRevision => (Branch == "main" ? "" : $"{Branch}_") + $"r{CommitHash}_{Build}";
+
///
/// The server's branding (environment version) to show to LBP clients. Shows the environment name next to the
/// revision.
@@ -81,20 +19,15 @@ public static partial class VersionHelper
public static string EnvVer => $"{ServerConfiguration.Instance.Customization.EnvironmentName} {FullRevision}";
public static string FullVersion =>
$"Project Lighthouse {ServerConfiguration.Instance.Customization.EnvironmentName} {Branch}@{CommitHash} {Build}";
- public static bool IsDirty => CommitHash.EndsWith("-dirty") ||
- CommitsOutOfDate != 1 ||
- CommitHash == "invalid" ||
- Branch == "invalid";
- public static int CommitsOutOfDate { get; set; }
- public static bool CanCheckForUpdates { get; set; }
- public static string[] Remotes { get; set; }
+ public static bool IsDirty => ThisAssembly.Git.IsDirty;
+ public static string RepositoryUrl => ThisAssembly.Git.RepositoryUrl;
public const string Build =
-#if DEBUG
+ #if DEBUG
"Debug";
-#elif RELEASE
+ #elif RELEASE
"Release";
-#else
- "Unknown";
-#endif
+ #else
+ "Unknown";
+ #endif
}
\ No newline at end of file
diff --git a/ProjectLighthouse/ProjectLighthouse.csproj b/ProjectLighthouse/ProjectLighthouse.csproj
index 948b49f5..3af05bd3 100644
--- a/ProjectLighthouse/ProjectLighthouse.csproj
+++ b/ProjectLighthouse/ProjectLighthouse.csproj
@@ -10,6 +10,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
@@ -29,33 +33,8 @@
-
-
-
- Always
-
-
-
- Always
-
-
-
- Always
-
-
-
- Always
-
-
-
-
-
-
-
-
-
-
+
diff --git a/ProjectLighthouse/StartupTasks.cs b/ProjectLighthouse/StartupTasks.cs
index 32a92941..6777b510 100644
--- a/ProjectLighthouse/StartupTasks.cs
+++ b/ProjectLighthouse/StartupTasks.cs
@@ -53,6 +53,13 @@ public static class StartupTasks
// Version info depends on ServerConfig
Logger.Info($"You are running version {VersionHelper.FullVersion}", LogArea.Startup);
+ if (VersionHelper.IsDirty)
+ {
+ Logger.Warn("This is a modified version of Project Lighthouse. " +
+ "Please make sure you are properly disclosing the source code to any users who may be using this instance.",
+ LogArea.Startup);
+ }
+
Logger.Info("Connecting to the database...", LogArea.Startup);
await using DatabaseContext database = DatabaseContext.CreateNewInstance();