From 56dd792e936f1861fe45155c64d8a2099d4bb88d Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Wed, 30 Jun 2021 20:49:12 -0700 Subject: [PATCH] Update docs metadata mutation logic --- eng/common/scripts/Update-DocsMsMetadata.ps1 | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/eng/common/scripts/Update-DocsMsMetadata.ps1 b/eng/common/scripts/Update-DocsMsMetadata.ps1 index 2a9d4f26a9..fccb663fa5 100644 --- a/eng/common/scripts/Update-DocsMsMetadata.ps1 +++ b/eng/common/scripts/Update-DocsMsMetadata.ps1 @@ -50,10 +50,16 @@ $releaseReplaceRegex = "(https://github.com/$RepoId/(?:blob|tree)/)(?:master|mai $TITLE_REGEX = "(\#\s+(?Azure .+? (?:client|plugin|shared) library for (?:JavaScript|Java|Python|\.NET|C)))" function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata) { - # Normalize service name "Key Vault" -> "keyvault" - # TODO: Use taxonomy for service name -- https://github.com/Azure/azure-sdk-tools/issues/1442 - # probably from metadata - $service = $PackageMetadata.ServiceName.ToLower().Replace(" ", "") + # The $PackageMetadata could be $null if there is no associated metadata entry + # based on how the metadata CSV is filtered + $service = $PackageInfo.ServiceDirectory.ToLower() + if ($PackageMetadata -and $PackageMetadata.ServiceName) { + # Normalize service name "Key Vault" -> "keyvault" + # TODO: Use taxonomy for service name -- https://github.com/Azure/azure-sdk-tools/issues/1442 + # probably from metadata + $service = $PackageMetadata.ServiceName.ToLower().Replace(" ", "") + } + # Generate the release tag for use in link substitution $tag = "$($PackageInfo.Name)_$($PackageInfo.Version)" $date = Get-Date -Format "MM/dd/yyyy" @@ -110,11 +116,14 @@ function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation) { $packageMetadataArray = (Get-CSVMetadata).Where({ $_.Package -eq $packageInfo.Name -and $_.GroupId -eq $packageInfo.Group -and $_.Hide -ne 'true' -and $_.New -eq 'true' }) if ($packageMetadataArray.Count -eq 0) { - LogError "Could not retrieve metadata for $($packageInfo.Name) from metadata CSV" + LogWarning "Could not retrieve metadata for $($packageInfo.Name) from metadata CSV. Using best effort defaults." + $packageMetadata = $null } elseif ($packageMetadataArray.Count -gt 1) { LogWarning "Multiple metadata entries for $($packageInfo.Name) in metadata CSV. Using first entry." + $packageMetadata = $packageMetadataArray[0] + } else { + $packageMetadata = $packageMetadataArray[0] } - $packageMetadata = $packageMetadataArray[0] $readmeContent = Get-Content $packageInfo.ReadMePath -Raw $outputReadmeContent = ""