Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 8152 (Azure#22778)
Browse files Browse the repository at this point in the history
* Only make one call to GetPackageInfoJson

* fix copy/paste, it should be packageInfoLocation not packageInfoJsonLocation

---------

Co-authored-by: James Suplizio <[email protected]>
  • Loading branch information
azure-sdk and JimSuplizio authored Apr 23, 2024
1 parent b37f69f commit 01eb170
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions eng/common/scripts/Update-DocsMsMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ function GetPackageInfoJson ($packageInfoJsonLocation) {
return $packageInfo
}

function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation) {
$packageInfo = GetPackageInfoJson $packageInfoJsonLocation
function UpdateDocsMsMetadataForPackage($packageInfo, $packageMetadataName) {

$originalVersion = [AzureEngSemanticVersion]::ParseVersionString($packageInfo.Version)
$packageMetadataArray = (Get-CSVMetadata).Where({ $_.Package -eq $packageInfo.Name -and $_.Hide -ne 'true' -and $_.New -eq 'true' })
Expand All @@ -150,7 +149,6 @@ function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation) {
$metadataMoniker = 'preview'
$readMePath = $docsMsMetadata.PreviewReadMeLocation
}
$packageMetadataName = Split-Path $packageInfoJsonLocation -Leaf
$packageInfoLocation = Join-Path $DocRepoLocation "metadata/$metadataMoniker"
if (Test-Path "$packageInfoLocation/$packageMetadataName") {
Write-Host "The docs metadata json $packageMetadataName exists, updating..."
Expand Down Expand Up @@ -193,10 +191,10 @@ function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation) {
$allSucceeded = $true
foreach ($packageInfoLocation in $PackageInfoJsonLocations) {

$packageInfo = GetPackageInfoJson $packageInfoLocation

if ($ValidateDocsMsPackagesFn -and (Test-Path "Function:$ValidateDocsMsPackagesFn")) {
Write-Host "Validating the packages..."

$packageInfo = GetPackageInfoJson $packageInfoLocation
# This calls a function named "Validate-${Language}-DocMsPackages"
# declared in common.ps1, implemented in Language-Settings.ps1
$isValid = &$ValidateDocsMsPackagesFn `
Expand All @@ -216,8 +214,9 @@ foreach ($packageInfoLocation in $PackageInfoJsonLocations) {
}

Write-Host "Updating metadata for package: $packageInfoLocation"
$packageMetadataName = Split-Path $packageInfoLocation -Leaf
# Convert package metadata json file to metadata json property.
UpdateDocsMsMetadataForPackage $packageInfoLocation
UpdateDocsMsMetadataForPackage $packageInfo $packageMetadataName
}

# Set a variable which will be used by the pipeline later to fail the build if
Expand Down

0 comments on commit 01eb170

Please sign in to comment.