diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
index 049c217efb..5faa30dbd2 100644
--- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
@@ -377,6 +377,7 @@ namespace Tgstation.Server.Host.Components.Chat
///
public Func> QueueDeploymentMessage(
Models.RevisionInformation revisionInformation,
+ Models.RevisionInformation? previousRevisionInformation,
EngineVersion engineVersion,
DateTimeOffset? estimatedCompletionTime,
string? gitHubOwner,
@@ -407,6 +408,7 @@ namespace Tgstation.Server.Host.Components.Chat
{
var callback = await provider.SendUpdateMessage(
revisionInformation,
+ previousRevisionInformation,
engineVersion,
estimatedCompletionTime,
gitHubOwner,
diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs
index 8a0aa33fe4..669f21b305 100644
--- a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs
@@ -61,6 +61,7 @@ namespace Tgstation.Server.Host.Components.Chat
/// Send the message for a deployment to configured deployment channels.
///
/// The of the deployment.
+ /// The optional of the previous deployment.
/// The of the deployment.
/// The optional the deployment is expected to be completed at.
/// The repository GitHub owner, if any.
@@ -69,6 +70,7 @@ namespace Tgstation.Server.Host.Components.Chat
/// A to call to update the message at the deployment's conclusion. Parameters: Error message if any, DreamMaker output if any. Returns an to call to mark the deployment as active/inactive. Parameter: If the deployment is being activated or inactivated.
Func> QueueDeploymentMessage(
Models.RevisionInformation revisionInformation,
+ Models.RevisionInformation? previousRevisionInformation,
Api.Models.EngineVersion engineVersion,
DateTimeOffset? estimatedCompletionTime,
string? gitHubOwner,
diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs
index 7012a94baf..fab0ae4f51 100644
--- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs
@@ -303,6 +303,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
///
public override async ValueTask>>> SendUpdateMessage(
Models.RevisionInformation revisionInformation,
+ Models.RevisionInformation? previousRevisionInformation,
EngineVersion engineVersion,
DateTimeOffset? estimatedCompletionTime,
string? gitHubOwner,
@@ -316,7 +317,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
localCommitPushed |= revisionInformation.CommitSha == revisionInformation.OriginCommitSha;
- var fields = BuildUpdateEmbedFields(revisionInformation, engineVersion, gitHubOwner, gitHubRepo, localCommitPushed);
+ var fields = BuildUpdateEmbedFields(revisionInformation, previousRevisionInformation, engineVersion, gitHubOwner, gitHubRepo, localCommitPushed);
Optional author = new EmbedAuthor(assemblyInformationProvider.VersionPrefix)
{
Url = "https://github.com/tgstation/tgstation-server",
@@ -900,6 +901,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
/// Create a of s for a discord update embed.
///
/// The of the deployment.
+ /// The optional of the previous deployment.
/// The of the deployment.
/// The repository GitHub owner, if any.
/// The repository GitHub name, if any.
@@ -907,6 +909,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
/// A new of s to use.
List BuildUpdateEmbedFields(
Models.RevisionInformation revisionInformation,
+ Models.RevisionInformation? previousRevisionInformation,
EngineVersion engineVersion,
string? gitHubOwner,
string? gitHubRepo,
@@ -936,6 +939,40 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
if (gitHubOwner == null || gitHubRepo == null)
return fields;
+ previousRevisionInformation ??= new Models.RevisionInformation();
+ previousRevisionInformation.ActiveTestMerges ??= new List();
+
+ revisionInformation.ActiveTestMerges ??= new List();
+
+ var addedTestMerges = revisionInformation
+ .ActiveTestMerges
+ .Select(x => x.TestMerge)
+ .Where(x => !previousRevisionInformation
+ .ActiveTestMerges
+ .Any(y => y.TestMerge.Number == x.Number))
+ .ToList();
+ var removedTestMerges = previousRevisionInformation
+ .ActiveTestMerges
+ .Select(x => x.TestMerge)
+ .Where(x => !revisionInformation
+ .ActiveTestMerges
+ .Any(y => y.TestMerge.Number == x.Number))
+ .ToList();
+ var updatedTestMerges = revisionInformation
+ .ActiveTestMerges
+ .Select(x => x.TestMerge)
+ .Where(x => previousRevisionInformation
+ .ActiveTestMerges
+ .Any(y => y.TestMerge.Number == x.Number && y.TestMerge.TargetCommitSha != x.TargetCommitSha))
+ .ToList();
+ var unchangedTestMerges = revisionInformation
+ .ActiveTestMerges
+ .Select(x => x.TestMerge)
+ .Where(x => previousRevisionInformation
+ .ActiveTestMerges
+ .Any(y => y.TestMerge.Number == x.Number && y.TestMerge.TargetCommitSha == x.TargetCommitSha))
+ .ToList();
+
fields.Add(
new EmbedField(
"Local Commit",
@@ -952,13 +989,35 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
: revisionOriginSha[..7],
true));
- fields.AddRange((revisionInformation.ActiveTestMerges ?? Enumerable.Empty())
- .Select(x => x.TestMerge)
+ fields.AddRange(addedTestMerges
+ .Select(x => new EmbedField(
+ $"#{x.Number} (Added)",
+ $"[{x.TitleAtMerge}]({x.Url}) by _[@{x.Author}](https://github.com/{x.Author})_{Environment.NewLine}Commit: [{x.TargetCommitSha![..7]}](https://github.com/{gitHubOwner}/{gitHubRepo}/commit/{x.TargetCommitSha}){(String.IsNullOrWhiteSpace(x.Comment) ? String.Empty : $"{Environment.NewLine}_**{x.Comment}**_")}",
+ false)));
+
+ fields.AddRange(updatedTestMerges
+ .Select(x => new EmbedField(
+ $"#{x.Number} (Updated)",
+ $"[{x.TitleAtMerge}]({x.Url}) by _[@{x.Author}](https://github.com/{x.Author})_{Environment.NewLine}Commit: [{x.TargetCommitSha![..7]}](https://github.com/{gitHubOwner}/{gitHubRepo}/commit/{x.TargetCommitSha}){(String.IsNullOrWhiteSpace(x.Comment) ? String.Empty : $"{Environment.NewLine}_**{x.Comment}**_")}",
+ false)));
+
+ fields.AddRange(unchangedTestMerges
.Select(x => new EmbedField(
$"#{x.Number}",
$"[{x.TitleAtMerge}]({x.Url}) by _[@{x.Author}](https://github.com/{x.Author})_{Environment.NewLine}Commit: [{x.TargetCommitSha![..7]}](https://github.com/{gitHubOwner}/{gitHubRepo}/commit/{x.TargetCommitSha}){(String.IsNullOrWhiteSpace(x.Comment) ? String.Empty : $"{Environment.NewLine}_**{x.Comment}**_")}",
false)));
+ if (removedTestMerges.Count != 0)
+ {
+ fields.Add(
+ new EmbedField(
+ "Removed:",
+ String.Join(
+ Environment.NewLine,
+ removedTestMerges
+ .Select(x => $"- #{x.Number} [{x.TitleAtMerge}]({x.Url}) by _[@{x.Author}](https://github.com/{x.Author})_"))));
+ }
+
return fields;
}
diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs
index 845892d9e0..9264f43a0e 100644
--- a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs
@@ -84,6 +84,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
/// Send the message for a deployment.
///
/// The of the deployment.
+ /// The optional of the previous deployment.
/// The of the deployment.
/// The optional the deployment is expected to be completed at.
/// The repository GitHub owner, if any.
@@ -94,6 +95,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
/// A resulting in a to call to update the message at the deployment's conclusion. Parameters: Error message if any, DreamMaker output if any. Returns another callback which should be called to mark the deployment as active.
ValueTask>>> SendUpdateMessage(
Models.RevisionInformation revisionInformation,
+ Models.RevisionInformation? previousRevisionInformation,
Api.Models.EngineVersion engineVersion,
DateTimeOffset? estimatedCompletionTime,
string? gitHubOwner,
diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs
index 2aa9916bf7..7ce331065f 100644
--- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs
@@ -17,6 +17,7 @@ using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.Jobs;
+using Tgstation.Server.Host.Models;
using Tgstation.Server.Host.System;
using Tgstation.Server.Host.Utils;
@@ -217,6 +218,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
///
public override async ValueTask>>> SendUpdateMessage(
Models.RevisionInformation revisionInformation,
+ Models.RevisionInformation? previousRevisionInformation,
EngineVersion engineVersion,
DateTimeOffset? estimatedCompletionTime,
string? gitHubOwner,
@@ -230,6 +232,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
ArgumentNullException.ThrowIfNull(gitHubOwner);
ArgumentNullException.ThrowIfNull(gitHubRepo);
+ previousRevisionInformation ??= new Models.RevisionInformation();
+ previousRevisionInformation.ActiveTestMerges ??= new List();
+
var commitInsert = revisionInformation.CommitSha![..7];
string remoteCommitInsert;
if (revisionInformation.CommitSha == revisionInformation.OriginCommitSha)
@@ -252,9 +257,26 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
.Select(x => x.TestMerge)
.Select(x =>
{
+ var status = string.Empty;
+ if (!previousRevisionInformation.ActiveTestMerges.Any(y => y.TestMerge.Number == x.Number))
+ {
+ status = "Added";
+ }
+ else if (revisionInformation.ActiveTestMerges!.Any(y => y.TestMerge.Number == x.Number && y.TestMerge.TargetCommitSha != x.TargetCommitSha))
+ {
+ status = "Updated";
+ }
+
var result = String.Format(CultureInfo.InvariantCulture, "#{0} at {1}", x.Number, x.TargetCommitSha![..7]);
if (x.Comment != null)
- result += String.Format(CultureInfo.InvariantCulture, " ({0})", x.Comment);
+ {
+ result += String.Format(CultureInfo.InvariantCulture, " ({1} - {0})", x.Comment, status);
+ }
+ else if (!string.IsNullOrEmpty(status))
+ {
+ result += String.Format(CultureInfo.InvariantCulture, " ({0})", status);
+ }
+
return result;
})));
diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs
index 6be6b71521..e1f58b8288 100644
--- a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs
@@ -199,6 +199,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
///
public abstract ValueTask>>> SendUpdateMessage(
RevisionInformation revisionInformation,
+ RevisionInformation? previousRevisionInformation,
Api.Models.EngineVersion engineVersion,
DateTimeOffset? estimatedCompletionTime,
string? gitHubOwner,
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs
index eab48e8172..75d31bc5d7 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs
@@ -326,7 +326,7 @@ namespace Tgstation.Server.Host.Components.Deployment
likelyPushedTestMergeCommit,
cancellationToken);
- var activeCompileJob = await compileJobConsumer.LatestCompileJob();
+ var oldCompileJob = await compileJobConsumer.LatestCompileJob();
try
{
await databaseContextFactory.UseContext(
@@ -374,7 +374,7 @@ namespace Tgstation.Server.Host.Components.Deployment
var commentsTask = remoteDeploymentManager!.PostDeploymentComments(
compileJob,
- activeCompileJob?.RevisionInformation,
+ oldCompileJob?.RevisionInformation,
repositorySettings,
repoOwner,
repoName,
@@ -478,8 +478,10 @@ namespace Tgstation.Server.Host.Components.Deployment
try
{
using var engineLock = await engineManager.UseExecutables(null, null, cancellationToken);
+ var oldCompileJob = await compileJobConsumer.LatestCompileJob();
currentChatCallback = chatManager.QueueDeploymentMessage(
revisionInformation,
+ oldCompileJob?.RevisionInformation,
engineLock.Version,
DateTimeOffset.UtcNow + estimatedDuration,
repository.RemoteRepositoryOwner,
diff --git a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs
index b82cf58226..ea6324cbcf 100644
--- a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs
+++ b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs
@@ -105,6 +105,7 @@ namespace Tgstation.Server.Tests.Live
public override ValueTask>>> SendUpdateMessage(
RevisionInformation revisionInformation,
+ RevisionInformation previousRevisionInformation,
Api.Models.EngineVersion engineVersion,
DateTimeOffset? estimatedCompletionTime,
string gitHubOwner,