From b28496a9fbee60a337e22ba391c69193e5840681 Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Mon, 22 Nov 2021 17:31:43 -0800 Subject: [PATCH] Fixed the get-codeowner in release step. (#3130) --- .../stages/archetype-cpp-release.yml | 41 ++----------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/eng/pipelines/templates/stages/archetype-cpp-release.yml b/eng/pipelines/templates/stages/archetype-cpp-release.yml index 710532bad..cd56d008c 100644 --- a/eng/pipelines/templates/stages/archetype-cpp-release.yml +++ b/eng/pipelines/templates/stages/archetype-cpp-release.yml @@ -170,47 +170,14 @@ stages: CloseAfterOpenForTesting: '${{ parameters.TestPipeline }}' - pwsh: | - # "person1,person2,Azure/group-name,person3" -> - # "@person1, @person2, @person3" - function getFormattedNotifableOwners($rawOwners) { - # If the list of owners is empty return an emtpy - # string - if (!$rawOwners) { - return '' - } - - $owners = @() - foreach ($owner in $rawOwners -split ',') { - # Exclude groups. GitHub does not notify teams - # that have different owners (e.g. alerting - # @Azure/example-team when opening a PR in - # Microsoft/vcpkg) - if ($owner.indexOf('/') -ne -1) { - continue - } - - $owners += "@$owner" - } - return $owners -join ', ' - } - - $prOwners = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 ` + $codeOwnersToNotify = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 ` -TargetDirectory "/sdk/${{ parameters.ServiceDirectory }}/" ` - -RootDirectory "$(Build.SourcesDirectory)" - - $codeOwnersToNotify = getFormattedNotifableOwners -rawOwners $prOwners - - # If there are no codeowners fall back to owners of /sdk/ - if (!$codeOwnersToNotify) { - $fallbackOwners = $(Build.SourcesDirectory)/eng/common/scripts/get-codeowners.ps1 ` - -TargetDirectory "/sdk/" ` - -RootDirectory "$(Build.SourcesDirectory)" - $codeOwnersToNotify = getFormattedNotifableOwners -rawOwners $fallbackOwners - } + -CodeOwnerFileLocation "$(Build.SourcesDirectory)/.github/CODEOWNERS" $prComment = "Adding ${{ artifact.Name }} to release" if ($codeOwnersToNotify) { - $prComment += "`n`ncc: $codeOwnersToNotify" + $codeOwners = $codeOwnersToNotify.ForEach({ "@$_" }) -join ", " + $prComment += "`n`ncc: $codeOwners" } ./eng/common/scripts/Add-IssueComment.ps1 `