Address requested changes

This commit is contained in:
Drulikar
2025-02-17 22:53:57 -06:00
parent 3b08f4ed02
commit 3bd3befdc4
4 changed files with 9 additions and 15 deletions
@@ -32,15 +32,6 @@
<WriteLinesToFile File="$(OutputFile)" Lines="$([System.IO.File]::ReadAllText($(InputFile)).Replace('/ &lt;auto-generated/&gt;','/ &lt;auto-generated /&gt;%0d%0a#pragma warning disable'))" Overwrite="true" Encoding="Unicode" />
</Target>
<ItemGroup>
<GraphQL Remove="GQL\Mutations\CreateNote.graphql" />
<GraphQL Remove="GQL\Mutations\ModifyNote.graphql" />
<GraphQL Remove="GQL\Queries\GetCurrentUser.graphql" />
<GraphQL Remove="GQL\Queries\GetMergeRequest.graphql" />
<GraphQL Remove="GQL\Queries\GetMergeRequestNotes.graphql" />
<GraphQL Remove="GQL\Queries\GetMergeRequests.graphql" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="StrawberryShake.Server" Version="15.0.3" />
</ItemGroup>
@@ -18,6 +18,11 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
/// </summary>
abstract class BaseRemoteDeploymentManager : IRemoteDeploymentManager
{
/// <summary>
/// The header comment that begins every deployment message comment/note.
/// </summary>
public const string DeploymentMsgHeaderStart = "<!-- tgs_test_merge_comment -->";
/// <summary>
/// The <see cref="Api.Models.Instance"/> for the <see cref="BaseRemoteDeploymentManager"/>.
/// </summary>
@@ -282,10 +282,9 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
try
{
string headerStart = "<!-- test_merge_tgs_bot -->";
string header = String.Format(CultureInfo.InvariantCulture, "{1}{0}## Test merge deployment history:{0}{0}", Environment.NewLine, headerStart);
string header = String.Format(CultureInfo.InvariantCulture, "{1}{0}## Test merge deployment history:{0}{0}", Environment.NewLine, DeploymentMsgHeaderStart);
var existingComment = await gitHubService.GetExistingCommentOnIssue(remoteRepositoryOwner, remoteRepositoryName, headerStart, testMergeNumber, cancellationToken);
var existingComment = await gitHubService.GetExistingCommentOnIssue(remoteRepositoryOwner, remoteRepositoryName, DeploymentMsgHeaderStart, testMergeNumber, cancellationToken);
if (existingComment != null)
{
await gitHubService.AppendCommentOnIssue(remoteRepositoryOwner, remoteRepositoryName, comment, existingComment, cancellationToken);
@@ -163,8 +163,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
await using var client = await GraphQLGitLabClientFactory.CreateClient(repositorySettings.AccessToken);
try
{
string headerStart = "<!-- test_merge_tgs_bot -->";
string header = String.Format(CultureInfo.InvariantCulture, "{1}{0}## Test merge deployment history:{0}{0}", Environment.NewLine, headerStart);
string header = String.Format(CultureInfo.InvariantCulture, "{1}{0}## Test merge deployment history:{0}{0}", Environment.NewLine, DeploymentMsgHeaderStart);
// Try to find an existing note
var notesQueryResult = await client.GraphQL.GetMergeRequestNotes.ExecuteAsync(
@@ -188,7 +187,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
for (int i = comments.Count - 1; i > -1; i--)
{
var currentComment = comments[i];
if (currentComment?.Author?.Username == repositorySettings.AccessUser && (currentComment?.Body?.StartsWith(headerStart) ?? false))
if (currentComment?.Author?.Username == repositorySettings.AccessUser && (currentComment?.Body?.StartsWith(DeploymentMsgHeaderStart) ?? false))
{
if (currentComment.Body.Length > 987856)
{ // Limit should be 999,999 so we'll leave a 12,143 buffer