From afb6192b3e8d002f2128391ee0202f99cf309632 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 20 Apr 2024 11:19:11 -0400 Subject: [PATCH] Add repo reference to CompileStart event Closes #1356 --- .../Components/Deployment/DreamMaker.cs | 2 ++ src/Tgstation.Server.Host/Components/Events/EventType.cs | 2 +- .../Components/Repository/Repository.cs | 5 +++++ tests/Tgstation.Server.Tests/TestRepository.cs | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs index 27107f7ff8..de540bff62 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs @@ -571,6 +571,7 @@ namespace Tgstation.Server.Host.Components.Deployment progressReporter.StageName = "Copying repository"; var resolvedOutputDirectory = ioManager.ResolvePath(outputDirectory); var repoOrigin = repository.Origin; + var repoReference = repository.Reference; using (repository) await repository.CopyTo(resolvedOutputDirectory, cancellationToken); @@ -585,6 +586,7 @@ namespace Tgstation.Server.Host.Components.Deployment resolvedOutputDirectory, repoOrigin.ToString(), engineLock.Version.ToString(), + repoReference, }, true, cancellationToken); diff --git a/src/Tgstation.Server.Host/Components/Events/EventType.cs b/src/Tgstation.Server.Host/Components/Events/EventType.cs index 4872998c61..5d8c0b9054 100644 --- a/src/Tgstation.Server.Host/Components/Events/EventType.cs +++ b/src/Tgstation.Server.Host/Components/Events/EventType.cs @@ -55,7 +55,7 @@ EngineActiveVersionChange, /// - /// After the repo is copied, before CodeModifications are applied. Parameters: Game directory path, origin commit sha, engine version string. + /// After the repo is copied, before CodeModifications are applied. Parameters: Game directory path, origin commit sha, engine version string, repository reference (or "(no branch)" if there is no reference). /// [EventScript("PreCompile")] CompileStart, diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index 2a362ff90c..972fae31cc 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -46,6 +46,11 @@ namespace Tgstation.Server.Host.Components.Repository /// public const string RemoteTemporaryBranchName = "___TGSTempBranch"; + /// + /// The value of when not on a reference. + /// + public const string NoReference = "(no branch)"; + /// /// Used when a reference cannot be determined. /// diff --git a/tests/Tgstation.Server.Tests/TestRepository.cs b/tests/Tgstation.Server.Tests/TestRepository.cs index a9b3ca4305..e73731de40 100644 --- a/tests/Tgstation.Server.Tests/TestRepository.cs +++ b/tests/Tgstation.Server.Tests/TestRepository.cs @@ -46,6 +46,9 @@ namespace Tgstation.Server.Tests const string StartSha = "af4da8beb9f9b374b04a3cc4d65acca662e8cc1a"; await repo.CheckoutObject(StartSha, null, null, true, new JobProgressReporter(Mock.Of>(), null, (stage, progress) => { }), CancellationToken.None); + + Assert.AreEqual(Host.Components.Repository.Repository.NoReference, repo.Reference); + var result = await repo.CommittishIsParent("2f8588a3ca0f6b027704a2a04381215619de3412", CancellationToken.None); Assert.IsTrue(result); Assert.AreEqual(StartSha, repo.Head);