Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 2095 (#18149)
Browse files Browse the repository at this point in the history
* Mitigate relative path calculation error on multiple iterations

* Revert "Mitigate relative path calculation error on multiple iterations"

This reverts commit 45baedd990c6a3085742a38a4891d8706a93be77.

* GetRelativePath should check if path is already relative before calling [IO.Path]::GetRelativePath

Co-authored-by: Daniel Jurek <[email protected]>
  • Loading branch information
azure-sdk and danieljurek authored Oct 13, 2021
1 parent 0afa58e commit ac86a56
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions eng/common/scripts/Save-Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ function GetRelativePath($path) {
if (!$path) {
return ''
}

# If the path is already relative return the path. Calling `GetRelativePath`
# on a relative path converts the relative path to an absolute path based on
# the current working directory which can result in unexpected outputs.
if (![IO.Path]::IsPathRooted($path)) {
return $path
}

$relativeTo = Resolve-Path $PSScriptRoot/../../../
# Replace "\" with "/" so the path is valid across other platforms and tools
$relativePath = [IO.Path]::GetRelativePath($relativeTo, $path) -replace "\\", '/'
Expand Down

0 comments on commit ac86a56

Please sign in to comment.