From 1aeb602efc94f105d1f7e0c579b39734b2808cd2 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Tue, 15 Sep 2020 18:43:45 +0000 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools repository for Tools PR 999 --- eng/common/scripts/update-docs-metadata.ps1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/eng/common/scripts/update-docs-metadata.ps1 b/eng/common/scripts/update-docs-metadata.ps1 index 34aa42801ec0e..1a1c4ba2b15bd 100644 --- a/eng/common/scripts/update-docs-metadata.ps1 +++ b/eng/common/scripts/update-docs-metadata.ps1 @@ -70,12 +70,15 @@ function GetAdjustedReadmeContent($pkgInfo, $lang){ } $fileContent = $pkgInfo.ReadmeContent - $foundTitle = "" # only replace the version if the formatted header can be found - $titleRegex = "(\# Azure .+? (?:client|plugin|shared) library for (?:JavaScript|Java|Python|\.NET|C))" - $fileContent = $pkgInfo.ReadmeContent -replace $titleRegex, "`${1} - Version $($pkgInfo.PackageVersion) `n" - + $titleRegex = "(\#\s+(?Azure .+? (?:client|plugin|shared) library for (?:JavaScript|Java|Python|\.NET|C)))" + $fileTitle = "" + if ($pkgInfo.ReadmeContent -match $titleRegex) { + $fileContent = $fileContent -replace $titleRegex, "`${0} - Version $($pkgInfo.PackageVersion) `n" + # The if block gurantee there is at least one match which starts with the format of "# Azure..." + $fileTitle = $matches["filetitle"] + } # Replace github master link with release tag. $ReplacementPattern = "`${1}$($pkgInfo.Tag)" $fileContent = $fileContent -replace $releaseReplaceRegex, $ReplacementPattern