From 4396011c59e2d438ab240f66507e22982227bd60 Mon Sep 17 00:00:00 2001 From: Djuradj Kurepa <91743470+dkurepa@users.noreply.github.com> Date: Tue, 20 Aug 2024 09:52:15 +0200 Subject: [PATCH] Use same logic as add-build-to-channel when checking default channels (#3846) --- .../src/PushMetadataToBuildAssetRegistry.cs | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/Maestro/Microsoft.DotNet.Maestro.Tasks/src/PushMetadataToBuildAssetRegistry.cs b/src/Maestro/Microsoft.DotNet.Maestro.Tasks/src/PushMetadataToBuildAssetRegistry.cs index 9037e4c2b3..a2d3b74165 100644 --- a/src/Maestro/Microsoft.DotNet.Maestro.Tasks/src/PushMetadataToBuildAssetRegistry.cs +++ b/src/Maestro/Microsoft.DotNet.Maestro.Tasks/src/PushMetadataToBuildAssetRegistry.cs @@ -196,28 +196,12 @@ public async Task PushMetadataAsync(CancellationToken cancellationToken) private async Task> GetBuildDefaultChannelsAsync(IMaestroApi client, Client.Models.Build recordedBuild) { - var defaultChannels = new List(); - if (recordedBuild.GitHubBranch != null && recordedBuild.GitHubRepository != null) - { - defaultChannels.AddRange( - await client.DefaultChannels.ListAsync( - branch: recordedBuild.GitHubBranch, - channelId: null, - enabled: true, - repository: recordedBuild.GitHubRepository - )); - } - - if (recordedBuild.AzureDevOpsBranch != null && recordedBuild.AzureDevOpsRepository != null) - { - defaultChannels.AddRange( - await client.DefaultChannels.ListAsync( - branch: recordedBuild.AzureDevOpsBranch, - channelId: null, - enabled: true, - repository: recordedBuild.AzureDevOpsRepository - )); - } + IEnumerable defaultChannels = await client.DefaultChannels.ListAsync( + branch: recordedBuild.GetBranch(), + channelId: null, + enabled: true, + repository: recordedBuild.GetRepository() + ); Log.LogMessage(MessageImportance.High, "Found the following default channels:"); foreach (var defaultChannel in defaultChannels)