Skip to content

Commit

Permalink
RunApiDiff.ps1: Fix bug setting wrong filenames and foldernames when …
Browse files Browse the repository at this point in the history
…comparing preview1 and previous version (dotnet#9177)

* Fix bug causing the incorrect creation of the subfolder for preview1 when comparing with the previous release.

* Also fix it for the readme files.

* Invert target folders to match the preview one first
  • Loading branch information
carlossanlop authored Feb 22, 2024
1 parent f59666e commit f424bc4
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions release-notes/RunApiDiff.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Function GetDotNetFullName
Param (
[Parameter(Mandatory=$true)]
[bool]
$areVersionsEqual
$IsComparingReleases
,
[Parameter(Mandatory=$true)]
[ValidatePattern("\d+\.\d")]
Expand All @@ -188,7 +188,7 @@ Function GetDotNetFullName
$previewNumberVersion # 0, 1, 2, 3, ...
)

If (-Not $areVersionsEqual)
If ($IsComparingReleases)
{
Return "$dotNetVersion.$previewNumberVersion"
}
Expand Down Expand Up @@ -313,18 +313,19 @@ Function GetPreviewFolderPath
,
[Parameter(Mandatory=$true)]
[bool]
$areVersionsEqual
$IsComparingReleases # True when comparing 8.0 GA with 9.0 GA
)

$prefixFolder = [IO.Path]::Combine($rootFolder, "release-notes", $dotNetVersion)
$apiDiffFolderName = "api-diff"
If ($areVersionsEqual)

If ($IsComparingReleases)
{
$previewOrRCFolderName = GetPreviewOrRCFolderName $dotNetVersion $previewOrRC $previewNumberVersion
Return [IO.Path]::Combine($prefixFolder, "preview", $apiDiffFolderName, $previewOrRCFolderName)
Return [IO.Path]::Combine($prefixFolder, "$dotNetVersion.$previewNumberVersion", $apiDiffFolderName)
}

Return [IO.Path]::Combine($prefixFolder, "$dotNetVersion.$previewNumberVersion", $apiDiffFolderName)
$previewOrRCFolderName = GetPreviewOrRCFolderName $dotNetVersion $previewOrRC $previewNumberVersion
Return [IO.Path]::Combine($prefixFolder, "preview", $previewOrRCFolderName, $apiDiffFolderName)
}

Function RunAsmDiff
Expand Down Expand Up @@ -564,10 +565,11 @@ Function DownloadPackage

## Generate strings with no whitespace

$areVersionsEqual = $PreviousDotNetVersion -eq $CurrentDotNetVersion
# True when comparing 8.0 GA with 9.0 GA
$IsComparingReleases = ($PreviousDotNetVersion -Ne $CurrentDotNetVersion) -And ($PreviousPreviewOrRC -Eq "ga") -And ($CurrentPreviewOrRC -eq "ga")

$previousDotNetFullName = GetDotNetFullName $areVersionsEqual $PreviousDotNetVersion $PreviousPreviewOrRC $PreviousPreviewNumberVersion
$currentDotNetFullName = GetDotNetFullName $areVersionsEqual $CurrentDotNetVersion $CurrentPreviewOrRC $CurrentPreviewNumberVersion
$previousDotNetFullName = GetDotNetFullName $IsComparingReleases $PreviousDotNetVersion $PreviousPreviewOrRC $PreviousPreviewNumberVersion
$currentDotNetFullName = GetDotNetFullName $IsComparingReleases $CurrentDotNetVersion $CurrentPreviewOrRC $CurrentPreviewNumberVersion


## Check folders passed as parameters exist
Expand Down Expand Up @@ -616,7 +618,7 @@ ReBuildIfExeNotFound $asmDiffExe $asmDiffProjectPath $asmDiffArtifactsPath

## Recreate api-diff folder in core repo folder

$previewFolderPath = GetPreviewFolderPath $CoreRepo $CurrentDotNetVersion $CurrentPreviewOrRC $CurrentPreviewNumberVersion $areVersionsEqual
$previewFolderPath = GetPreviewFolderPath $CoreRepo $CurrentDotNetVersion $CurrentPreviewOrRC $CurrentPreviewNumberVersion $IsComparingReleases
Write-Color cyan "Checking existing diff folder: $previewFolderPath"
RecreateFolder $previewFolderPath

Expand Down

0 comments on commit f424bc4

Please sign in to comment.