From 6525ebe3cb320164a0eb97ae038e45da0d3892cc Mon Sep 17 00:00:00 2001 From: Toru the Red Fox Date: Wed, 27 Jul 2022 21:03:44 +0100 Subject: [PATCH] lbpEnvVer parity (somewhat, GameServer) and player polaroid resolution fix (Website) (#373) * lbp2 beta tweaks * tweaks * oops * pls work * PLS * Update UserCardPartial.cshtml * news reimplementation testing trying to fix it for lbp1 * a * configurable envver * Make numeric revision numbers only usable on full clones * little comment to describe what EnvVer is * remove news (again) * remove redundancy when dirty * document envver stuff * remove numeric versioning for upstream merge * Revert "remove numeric versioning for upstream merge" This reverts commit 3e7d8eccbc76283561b7b3cbd7f4f66697e6bcb6. * Revert "Revert "remove numeric versioning for upstream merge"" This reverts commit 7fbe145b807bfe73e1c14ea2b61cc020a28676a9. * Delete gitIsShallowRepo.txt * accidentally deleted the wrong line oops * Update VersionHelper.cs Co-authored-by: Jayden --- .gitignore | 1 + .../Controllers/LoginController.cs | 2 +- .../Pages/Partials/UserCardPartial.cshtml | 2 +- .../Tests/AuthenticationTests.cs | 4 +- .../CustomizationConfiguration.cs | 1 + .../Configuration/ServerConfiguration.cs | 2 +- ProjectLighthouse/Helpers/VersionHelper.cs | 13 ++++- ProjectLighthouse/ProjectLighthouse.csproj | 50 +++++++++---------- 8 files changed, 44 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index 2783648d..b766f916 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ gitBranch.txt gitVersion.txt gitRemotes.txt gitUnpushed.txt +gitRevCount.txt logs/* npTicket* diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs index 441a1b6a..056a5cfe 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/LoginController.cs @@ -130,7 +130,7 @@ public class LoginController : ControllerBase new LoginResult { AuthTicket = "MM_AUTH=" + token.UserToken, - ServerBrand = VersionHelper.FullVersion, + ServerBrand = VersionHelper.EnvVer, }.Serialize() ); } diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/UserCardPartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/UserCardPartial.cshtml index 8e3386ea..06772c38 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/UserCardPartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/UserCardPartial.cshtml @@ -9,7 +9,7 @@ @{ int size = isMobile ? 50 : 100; } -
+
@if (showLink) diff --git a/ProjectLighthouse.Tests.GameApiTests/Tests/AuthenticationTests.cs b/ProjectLighthouse.Tests.GameApiTests/Tests/AuthenticationTests.cs index acfbfb6b..70fcf8bc 100644 --- a/ProjectLighthouse.Tests.GameApiTests/Tests/AuthenticationTests.cs +++ b/ProjectLighthouse.Tests.GameApiTests/Tests/AuthenticationTests.cs @@ -26,7 +26,7 @@ public class AuthenticationTests : LighthouseServerTest Assert.True(response.IsSuccessStatusCode); string responseContent = await response.Content.ReadAsStringAsync(); Assert.Contains("MM_AUTH=", responseContent); - Assert.Contains(VersionHelper.FullVersion, responseContent); + Assert.Contains(VersionHelper.EnvVer, responseContent); } [DatabaseFact] @@ -39,7 +39,7 @@ public class AuthenticationTests : LighthouseServerTest Assert.NotNull(loginResult.ServerBrand); Assert.Contains("MM_AUTH=", loginResult.AuthTicket); - Assert.Equal(VersionHelper.FullVersion, loginResult.ServerBrand); + Assert.Equal(VersionHelper.EnvVer, loginResult.ServerBrand); } [DatabaseFact] diff --git a/ProjectLighthouse/Configuration/ConfigurationCategories/CustomizationConfiguration.cs b/ProjectLighthouse/Configuration/ConfigurationCategories/CustomizationConfiguration.cs index 027c1753..ee6b17e4 100644 --- a/ProjectLighthouse/Configuration/ConfigurationCategories/CustomizationConfiguration.cs +++ b/ProjectLighthouse/Configuration/ConfigurationCategories/CustomizationConfiguration.cs @@ -3,4 +3,5 @@ namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories; public class CustomizationConfiguration { public string ServerName { get; set; } = "Project Lighthouse"; + public string EnvironmentName { get; set; } = "project-lighthouse"; } \ No newline at end of file diff --git a/ProjectLighthouse/Configuration/ServerConfiguration.cs b/ProjectLighthouse/Configuration/ServerConfiguration.cs index 41618860..f7d4aa05 100644 --- a/ProjectLighthouse/Configuration/ServerConfiguration.cs +++ b/ProjectLighthouse/Configuration/ServerConfiguration.cs @@ -23,7 +23,7 @@ public class ServerConfiguration // You can use an ObsoleteAttribute instead. Make sure you set it to error, though. // // Thanks for listening~ - public const int CurrentConfigVersion = 8; + public const int CurrentConfigVersion = 10; #region Meta diff --git a/ProjectLighthouse/Helpers/VersionHelper.cs b/ProjectLighthouse/Helpers/VersionHelper.cs index 212eb091..f78bf858 100644 --- a/ProjectLighthouse/Helpers/VersionHelper.cs +++ b/ProjectLighthouse/Helpers/VersionHelper.cs @@ -8,10 +8,13 @@ public static class VersionHelper { static VersionHelper() { + string commitNumber = "invalid"; try { CommitHash = ResourceHelper.ReadManifestFile("gitVersion.txt"); Branch = ResourceHelper.ReadManifestFile("gitBranch.txt"); + commitNumber = $"{CommitHash}_{Build}"; + FullRevision = (Branch == "main") ? $"r{commitNumber}" : $"{Branch}_r{commitNumber}"; string remotesFile = ResourceHelper.ReadManifestFile("gitRemotes.txt"); @@ -54,7 +57,15 @@ public static class VersionHelper public static string CommitHash { get; set; } public static string Branch { get; set; } - public static string FullVersion => $"Project Lighthouse {Branch}@{CommitHash} {Build} ({ServerConfiguration.Instance.Customization.ServerName})"; + /// + /// The full revision string. States current revision hash and, if not main, the branch. + /// + public static string FullRevision { get; set; } + /// + /// The server's branding (environment version) to show to LBP clients. Shows the environment name next to the revision. + /// + 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; } diff --git a/ProjectLighthouse/ProjectLighthouse.csproj b/ProjectLighthouse/ProjectLighthouse.csproj index 9989edc2..b54db9f9 100644 --- a/ProjectLighthouse/ProjectLighthouse.csproj +++ b/ProjectLighthouse/ProjectLighthouse.csproj @@ -1,4 +1,4 @@ - + Linux net6.0 @@ -28,26 +28,26 @@ - - - Always - - - - Always - - - - Always - - - - Always - - - - Always - + + + Always + + + + Always + + + + Always + + + + Always + + + + Always + @@ -59,9 +59,9 @@ - - - - + + + +