From 3e87c4495dddf6cfc4cb7ea12abe18835ccef2b0 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 28 Jul 2020 12:06:46 -0700 Subject: [PATCH] Restructure Changelog Logic --- .../templates/steps/verify-changelog.yml | 2 - ...perations.ps1 => Changelog-Operations.ps1} | 0 eng/common/scripts/Package-Properties.ps1 | 40 +++++++++---------- eng/common/scripts/Verify-ChangeLog.ps1 | 26 ++---------- 4 files changed, 22 insertions(+), 46 deletions(-) rename eng/common/scripts/{ChangeLog-Operations.ps1 => Changelog-Operations.ps1} (100%) diff --git a/eng/common/pipelines/templates/steps/verify-changelog.yml b/eng/common/pipelines/templates/steps/verify-changelog.yml index f6005124a87f..4f7c8d40dd92 100644 --- a/eng/common/pipelines/templates/steps/verify-changelog.yml +++ b/eng/common/pipelines/templates/steps/verify-changelog.yml @@ -16,8 +16,6 @@ steps: arguments: > -PackageName ${{ parameters.PackageName }} -ServiceName ${{ parameters.ServiceName }} - -RepoRoot $(Build.SourcesDirectory) - -RepoName $(Build.Repository.Name) -ForRelease $${{ parameters.ForRelease }} pwsh: true workingDirectory: $(Pipeline.Workspace) diff --git a/eng/common/scripts/ChangeLog-Operations.ps1 b/eng/common/scripts/Changelog-Operations.ps1 similarity index 100% rename from eng/common/scripts/ChangeLog-Operations.ps1 rename to eng/common/scripts/Changelog-Operations.ps1 diff --git a/eng/common/scripts/Package-Properties.ps1 b/eng/common/scripts/Package-Properties.ps1 index cba89157a879..cec80a5f2871 100644 --- a/eng/common/scripts/Package-Properties.ps1 +++ b/eng/common/scripts/Package-Properties.ps1 @@ -1,14 +1,13 @@ # Helper functions for retireving useful information from azure-sdk-for-* repo -# Example Use : Import-Module .\eng\common\scripts\modules class PackageProps { - [string]$pkgName - [string]$pkgVersion - [string]$pkgDirectoryPath - [string]$pkgServiceName - [string]$pkgReadMePath - [string]$pkgChangeLogPath - [string]$pkgGroup + [string]$Name + [string]$Version + [string]$DirectoryPath + [string]$ServiceName + [string]$ReadMePath + [string]$ChangeLogPath + [string]$Group PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName) { @@ -27,27 +26,27 @@ class PackageProps [string]$pkgServiceName ) { - $this.pkgName = $pkgName - $this.pkgVersion = $pkgVersion - $this.pkgDirectoryPath = $pkgDirectoryPath - $this.pkgServiceName = $pkgServiceName + $this.Name = $pkgName + $this.Version = $pkgVersion + $this.DirectoryPath = $pkgDirectoryPath + $this.ServiceName = $pkgServiceName if (Test-Path (Join-Path $pkgDirectoryPath "README.md")) { - $this.pkgReadMePath = Join-Path $pkgDirectoryPath "README.md" + $this.ReadMePath = Join-Path $pkgDirectoryPath "README.md" } else { - $this.pkgReadMePath = $null + $this.ReadMePath = $null } if (Test-Path (Join-Path $pkgDirectoryPath "CHANGELOG.md")) { - $this.pkgChangeLogPath = Join-Path $pkgDirectoryPath "CHANGELOG.md" + $this.ChangeLogPath = Join-Path $pkgDirectoryPath "CHANGELOG.md" } else { - $this.pkgChangeLogPath = $null + $this.ChangeLogPath = $null } } @@ -60,7 +59,7 @@ class PackageProps ) { $this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName) - $this.pkgGroup = $pkgGroup + $this.Group = $pkgGroup } } @@ -78,7 +77,6 @@ function Get-PkgProperties [string]$ServiceName ) - $pkgDirectoryName = $null $pkgDirectoryPath = $null $serviceDirectoryPath = Join-Path $RepoRoot "sdk" $ServiceName if (!(Test-Path $serviceDirectoryPath)) @@ -92,13 +90,13 @@ function Get-PkgProperties foreach ($directory in $directoriesPresent) { $pkgDirectoryPath = Join-Path $serviceDirectoryPath $directory.Name - if ($ExtractPkgProps) + if ($GetPackageInfoFromRepoFn) { - $pkgProps = &$ExtractPkgProps -pkgPath $pkgDirectoryPath -serviceName $ServiceName -pkgName $PackageName + $pkgProps = &$GetPackageInfoFromRepoFn -pkgPath $pkgDirectoryPath -serviceName $ServiceName -pkgName $PackageName } else { - Write-Error "The function '${ExtractPkgProps}' was not found." + Write-Error "The function 'Get-${Language}-PackageInfoFromRepo' was not found." } if ($pkgProps -ne $null) diff --git a/eng/common/scripts/Verify-ChangeLog.ps1 b/eng/common/scripts/Verify-ChangeLog.ps1 index 26218d988df2..d80faa88a6d1 100644 --- a/eng/common/scripts/Verify-ChangeLog.ps1 +++ b/eng/common/scripts/Verify-ChangeLog.ps1 @@ -4,16 +4,10 @@ param ( [String]$VersionString, [string]$PackageName, [string]$ServiceName, - [string]$RepoRoot, - [ValidateSet("net", "java", "js", "python")] - [string]$Language, - [string]$RepoName, [boolean]$ForRelease = $False ) -$ProgressPreference = "SilentlyContinue" -. (Join-Path $PSScriptRoot SemVer.ps1) -Import-Module (Join-Path $PSScriptRoot modules ChangeLog-Operations.psm1) +. (Join-Path $PSScriptRoot common.ps1) $validChangeLog = $false if ($ChangeLogLocation -and $VersionString) @@ -22,22 +16,8 @@ if ($ChangeLogLocation -and $VersionString) } else { - Import-Module (Join-Path $PSScriptRoot modules Package-Properties.psm1) - if ([System.String]::IsNullOrEmpty($Language)) - { - if ($RepoName -match "azure-sdk-for-(?[^-]+)") - { - $Language = $matches["lang"] - } - else - { - Write-Error "Failed to set Language automatically. Please pass the appropriate Language as a parameter." - exit 1 - } - } - - $PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceName $ServiceName -Language $Language -RepoRoot $RepoRoot - $validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.pkgChangeLogPath -VersionString $PackageProp.pkgVersion -ForRelease $ForRelease + $PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceName $ServiceName + $validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.ChangeLogPath -VersionString $PackageProp.Version -ForRelease $ForRelease } if (!$validChangeLog)