azure-sdk-for-cpp/eng/scripts/Get-PkgVersion.ps1
Ahson Khan fd9c3e5ebb
Fix true spelling errors across all source and header files within the SDK and add exceptions for false positives. (#2209)
Part of https://github.com/Azure/azure-sdk-for-cpp/issues/1277, checking what types of warnings the CI emits.

Verified all SDK product `.cpp`, `.hpp`, `.txt`, and `.md` files, primarily focused on azure-core. They are all clean now. There are some exceptions that needs to be added for keyvault and storage, but they are false positives, so not a concern.

> `cspell lint --config .vscode/cspell.json *.hpp */**/*.hpp`

CSpell: Files checked: 188, Issues found: 0 in 0 files

> `cspell lint --config .vscode/cspell.json *.cpp */**/*.cpp`

CSpell: Files checked: 186, Issues found: 88 in 15 files (keyvault and storage false positives, or tests)

> `cspell lint --config .vscode/cspell.json *.md */**/*.md`

CSpell: Files checked: 45, Issues found: 5 in 2 files (eng/common)

> `cspell lint --config .vscode/cspell.json *.txt */**/*.txt`

CSpell: Files checked: 44, Issues found: 0 in 0 files

> `cspell lint --config .vscode/cspell.json *.* */**/*`

CSpell: Files checked: 646, Issues found: 328 in 69 files (most of these are in eng\docs\api\assets\style.css or eng/common)

Deprioritize and ignored the errors from the test files (including test resource json files), and `eng/common` since those need to be centrally fixed.
2021-05-07 21:04:58 +00:00

49 lines
1.3 KiB
PowerShell

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $ServiceDirectory,
[Parameter(Mandatory = $true)]
[string] $PackageName
)
$repoRoot = Resolve-Path "$PSScriptRoot/../..";
. (Join-Path ${repoRoot} eng common scripts logging.ps1)
. (Join-Path ${repoRoot} eng scripts SdkVersion-Common.ps1)
$versionFileLocation = Get-VersionHppLocation `
-ServiceDirectory $ServiceDirectory `
-PackageName $PackageName
if (!$versionFileLocation) {
$fallbackpath = Join-Path $RepoRoot sdk $ServiceDirectory $PackageName version.txt
if (!(Test-Path $fallbackpath))
{
LogWarning "Failed to retrieve package version. No version file found."
return $null
}
$fallback = Get-Content $fallbackpath
if ($fallback) {
return $fallback
} else {
LogWarning "Cannot locate package version"
return $null
}
}
$versionFileContents = Get-Content $versionFileLocation -Raw
if (!($versionFileContents -match $VersionRegex)) {
LogWarning "does not match version information schema"
return $null
}
$VersionString = if ($Matches.prerelease) {
"$($Matches.major).$($Matches.minor).$($Matches.patch)-$($Matches.prerelease)"
} else {
"$($Matches.major).$($Matches.minor).$($Matches.patch)"
}
return $VersionString