mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-29 16:11:05 +01:00
Fix test merge comment posting
This commit is contained in:
@@ -602,13 +602,15 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
.CreateRemoteDeploymentManager(metadata, repo.RemoteGitProvider.Value);
|
||||
|
||||
var repoSha = repo.Head;
|
||||
repoOwner = repo.RemoteRepositoryOwner;
|
||||
repoName = repo.RemoteRepositoryName;
|
||||
revInfo = await databaseContext
|
||||
.RevisionInformations
|
||||
.AsQueryable()
|
||||
.Where(x => x.CommitSha == repoSha && x.Instance.Id == metadata.Id)
|
||||
.Include(x => x.ActiveTestMerges)
|
||||
.ThenInclude(x => x.TestMerge)
|
||||
.ThenInclude(x => x.MergedBy)
|
||||
.ThenInclude(x => x.TestMerge)
|
||||
.ThenInclude(x => x.MergedBy)
|
||||
.FirstOrDefaultAsync(cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
@@ -661,10 +663,12 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
await databaseContextFactory.UseContext(
|
||||
async databaseContext =>
|
||||
{
|
||||
var fullJob = compileJob.Job;
|
||||
compileJob.Job = new Models.Job
|
||||
{
|
||||
Id = job.Id
|
||||
};
|
||||
var fullRevInfo = compileJob.RevisionInformation;
|
||||
compileJob.RevisionInformation = new Models.RevisionInformation
|
||||
{
|
||||
Id = revInfo.Id
|
||||
@@ -690,6 +694,9 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
await databaseContext.Save(default).ConfigureAwait(false);
|
||||
throw;
|
||||
}
|
||||
|
||||
compileJob.Job = fullJob;
|
||||
compileJob.RevisionInformation = fullRevInfo;
|
||||
})
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
+32
-18
@@ -47,23 +47,49 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
|
||||
if (repositorySettings?.AccessToken == null)
|
||||
return;
|
||||
|
||||
if ((previousRevisionInformation != null && previousRevisionInformation.CommitSha == previousRevisionInformation.CommitSha)
|
||||
var deployedRevisionInformation = compileJob.RevisionInformation;
|
||||
if ((previousRevisionInformation != null && previousRevisionInformation.CommitSha == deployedRevisionInformation.CommitSha)
|
||||
|| !repositorySettings.PostTestMergeComment.Value)
|
||||
return;
|
||||
|
||||
previousRevisionInformation ??= new RevisionInformation();
|
||||
previousRevisionInformation.ActiveTestMerges ??= new List<RevInfoTestMerge>();
|
||||
|
||||
var deployedRevisionInformation = compileJob.RevisionInformation;
|
||||
deployedRevisionInformation.ActiveTestMerges ??= new List<RevInfoTestMerge>();
|
||||
var tasks = new List<Task>();
|
||||
|
||||
// added prs
|
||||
foreach (var I in deployedRevisionInformation
|
||||
var tmsAdded = deployedRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Select(x => x.TestMerge)
|
||||
.Where(x => !previousRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Any(y => y.TestMerge.Number == x.Number)))
|
||||
.Any(y => y.TestMerge.Number == x.Number))
|
||||
.ToList();
|
||||
var tmsRemoved = previousRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Select(x => x.TestMerge)
|
||||
.Where(x => !deployedRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Any(y => y.TestMerge.Number == x.Number))
|
||||
.ToList();
|
||||
var tmsUpdated = deployedRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Select(x => x.TestMerge)
|
||||
.Where(x => previousRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Any(y => y.TestMerge.Number == x.Number))
|
||||
.ToList();
|
||||
|
||||
if (!tmsAdded.Any() && !tmsRemoved.Any() && !tmsUpdated.Any())
|
||||
return;
|
||||
|
||||
Logger.LogTrace(
|
||||
"Commenting on {0} added, {1} removed, and {2} updated test merge sources...",
|
||||
tmsAdded.Count,
|
||||
tmsRemoved.Count,
|
||||
tmsUpdated.Count);
|
||||
foreach (var I in tmsAdded)
|
||||
tasks.Add(
|
||||
CommentOnTestMergeSource(
|
||||
repositorySettings,
|
||||
@@ -79,13 +105,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
|
||||
I.Number,
|
||||
cancellationToken));
|
||||
|
||||
// removed prs
|
||||
foreach (var I in previousRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Select(x => x.TestMerge)
|
||||
.Where(x => !deployedRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Any(y => y.TestMerge.Number == x.Number)))
|
||||
foreach (var I in tmsRemoved)
|
||||
tasks.Add(
|
||||
CommentOnTestMergeSource(
|
||||
repositorySettings,
|
||||
@@ -95,13 +115,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote
|
||||
I.Number,
|
||||
cancellationToken));
|
||||
|
||||
// updated prs
|
||||
foreach (var I in deployedRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Select(x => x.TestMerge)
|
||||
.Where(x => previousRevisionInformation
|
||||
.ActiveTestMerges
|
||||
.Any(y => y.TestMerge.Number == x.Number)))
|
||||
foreach (var I in tmsUpdated)
|
||||
tasks.Add(
|
||||
CommentOnTestMergeSource(
|
||||
repositorySettings,
|
||||
|
||||
Reference in New Issue
Block a user