Add repo reference to CompileStart event

Closes #1356
This commit is contained in:
Jordan Dominion
2024-04-20 11:19:11 -04:00
parent 01b0ad2612
commit afb6192b3e
4 changed files with 11 additions and 1 deletions
@@ -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);
@@ -55,7 +55,7 @@
EngineActiveVersionChange,
/// <summary>
/// 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).
/// </summary>
[EventScript("PreCompile")]
CompileStart,
@@ -46,6 +46,11 @@ namespace Tgstation.Server.Host.Components.Repository
/// </summary>
public const string RemoteTemporaryBranchName = "___TGSTempBranch";
/// <summary>
/// The value of <see cref="Reference"/> when not on a reference.
/// </summary>
public const string NoReference = "(no branch)";
/// <summary>
/// Used when a reference cannot be determined.
/// </summary>
@@ -46,6 +46,9 @@ namespace Tgstation.Server.Tests
const string StartSha = "af4da8beb9f9b374b04a3cc4d65acca662e8cc1a";
await repo.CheckoutObject(StartSha, null, null, true, new JobProgressReporter(Mock.Of<ILogger<JobProgressReporter>>(), 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);