This patch replaces PowerShell aliases for their real commands, see https://blogs.technet.microsoft.com/heyscriptingguy/2012/04/21/when-you-should-use-powershell-aliases/
For example;
- use `Get-Location` instead of `pwd`
- use `Set-Location` instead of `cd`
- use `ForEach-Object` instead of the `%` shorthand
- use `Write-Output` instead of `echo`
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -256,7 +256,7 @@ Try {
|
| 256 | 256 |
Get-ChildItem Env: | Out-String |
| 257 | 257 |
|
| 258 | 258 |
# PR |
| 259 |
- if (-not ($null -eq $env:PR)) { echo "INFO: PR#$env:PR (https://github.com/docker/docker/pull/$env:PR)" }
|
|
| 259 |
+ if (-not ($null -eq $env:PR)) { Write-Output "INFO: PR#$env:PR (https://github.com/docker/docker/pull/$env:PR)" }
|
|
| 260 | 260 |
|
| 261 | 261 |
# Make sure docker is installed |
| 262 | 262 |
if ($null -eq (Get-Command "docker" -ErrorAction SilentlyContinue)) { Throw "ERROR: docker is not installed or not found on path" }
|
| ... | ... |
@@ -291,12 +291,12 @@ Try {
|
| 291 | 291 |
} |
| 292 | 292 |
|
| 293 | 293 |
# Make sure we start at the root of the sources |
| 294 |
- cd "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker" |
|
| 295 |
- Write-Host -ForegroundColor Green "INFO: Running in $(pwd)" |
|
| 294 |
+ Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker" |
|
| 295 |
+ Write-Host -ForegroundColor Green "INFO: Running in $(Get-Location)" |
|
| 296 | 296 |
|
| 297 | 297 |
# Make sure we are in repo |
| 298 | 298 |
if (-not (Test-Path -PathType Leaf -Path ".\Dockerfile.windows")) {
|
| 299 |
- Throw "$(pwd) does not contain Dockerfile.windows!" |
|
| 299 |
+ Throw "$(Get-Location) does not contain Dockerfile.windows!" |
|
| 300 | 300 |
} |
| 301 | 301 |
Write-Host -ForegroundColor Green "INFO: docker/docker repository was found" |
| 302 | 302 |
|
| ... | ... |
@@ -835,7 +835,7 @@ Try {
|
| 835 | 835 |
"`$env`:PATH`='c`:\target;'+`$env:PATH`; `$env:DOCKER_HOST`='tcp`://'+(ipconfig | select -last 1).Substring(39)+'`:2357'; c:\target\runIntegrationCLI.ps1" | Out-Host } ) |
| 836 | 836 |
} else {
|
| 837 | 837 |
Write-Host -ForegroundColor Green "INFO: Integration tests being run from the host:" |
| 838 |
- cd "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli" |
|
| 838 |
+ Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli" |
|
| 839 | 839 |
$env:DOCKER_HOST=$DASHH_CUT |
| 840 | 840 |
$env:PATH="$env:TEMP\binary;$env:PATH;" # Force to use the test binaries, not the host ones. |
| 841 | 841 |
Write-Host -ForegroundColor Green "INFO: $c" |
| ... | ... |
@@ -901,7 +901,7 @@ Try {
|
| 901 | 901 |
$c += "`"-test.timeout`" " + "`"200m`" " |
| 902 | 902 |
|
| 903 | 903 |
Write-Host -ForegroundColor Green "INFO: LCOW Integration tests being run from the host:" |
| 904 |
- cd "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli" |
|
| 904 |
+ Set-Location "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\integration-cli" |
|
| 905 | 905 |
Write-Host -ForegroundColor Green "INFO: $c" |
| 906 | 906 |
Write-Host -ForegroundColor Green "INFO: DOCKER_HOST at $DASHH_CUT" |
| 907 | 907 |
# Explicit to not use measure-command otherwise don't get output as it goes |
| ... | ... |
@@ -988,7 +988,7 @@ Finally {
|
| 988 | 988 |
Copy-Item "$env:TEMP\dut.err" "$TEMPORIG\CIDUT.log" -Force -ErrorAction SilentlyContinue |
| 989 | 989 |
} |
| 990 | 990 |
|
| 991 |
- cd "$env:SOURCES_DRIVE\$env:SOURCES_SUBDIR" -ErrorAction SilentlyContinue |
|
| 991 |
+ Set-Location "$env:SOURCES_DRIVE\$env:SOURCES_SUBDIR" -ErrorAction SilentlyContinue |
|
| 992 | 992 |
Nuke-Everything |
| 993 | 993 |
$Dur=New-TimeSpan -Start $StartTime -End $(Get-Date) |
| 994 | 994 |
Write-Host -ForegroundColor $FinallyColour "`nINFO: executeCI.ps1 exiting at $(date). Duration $dur`n" |
| ... | ... |
@@ -218,7 +218,7 @@ Function Validate-DCO($headCommit, $upstreamCommit) {
|
| 218 | 218 |
if ($LASTEXITCODE -ne 0) { Throw "Failed git log --format" }
|
| 219 | 219 |
$commits = $($commits -split '\s+' -match '\S') |
| 220 | 220 |
$badCommits=@() |
| 221 |
- $commits | %{
|
|
| 221 |
+ $commits | ForEach-Object{
|
|
| 222 | 222 |
# Skip commits with no content such as merge commits etc |
| 223 | 223 |
if ($(git log -1 --format=format: --name-status $_).Length -gt 0) {
|
| 224 | 224 |
# Ignore exit code on next call - always process regardless |
| ... | ... |
@@ -244,7 +244,7 @@ Function Validate-PkgImports($headCommit, $upstreamCommit) {
|
| 244 | 244 |
|
| 245 | 245 |
# Get a list of go source-code files which have changed under pkg\. Ignore exit code on next call - always process regardless |
| 246 | 246 |
$files=@(); $files = Invoke-Expression "git diff $upstreamCommit...$headCommit --diff-filter=ACMR --name-only -- `'pkg\*.go`'" |
| 247 |
- $badFiles=@(); $files | %{
|
|
| 247 |
+ $badFiles=@(); $files | ForEach-Object{
|
|
| 248 | 248 |
$file=$_ |
| 249 | 249 |
# For the current changed file, get its list of dependencies, sorted and uniqued. |
| 250 | 250 |
$imports = Invoke-Expression "go list -e -f `'{{ .Deps }}`' $file"
|
| ... | ... |
@@ -255,13 +255,13 @@ Function Validate-PkgImports($headCommit, $upstreamCommit) {
|
| 255 | 255 |
-NotMatch "^github.com/docker/docker/vendor" ` |
| 256 | 256 |
-Match "^github.com/docker/docker" ` |
| 257 | 257 |
-Replace "`n", "" |
| 258 |
- $imports | % { $badFiles+="$file imports $_`n" }
|
|
| 258 |
+ $imports | ForEach-Object{ $badFiles+="$file imports $_`n" }
|
|
| 259 | 259 |
} |
| 260 | 260 |
if ($badFiles.Length -eq 0) {
|
| 261 | 261 |
Write-Host 'Congratulations! ".\pkg\*.go" is safely isolated from internal code.' |
| 262 | 262 |
} else {
|
| 263 | 263 |
$e = "`nThese files import internal code: (either directly or indirectly)`n" |
| 264 |
- $badFiles | %{ $e+=" - $_"}
|
|
| 264 |
+ $badFiles | ForEach-Object{ $e+=" - $_"}
|
|
| 265 | 265 |
Throw $e |
| 266 | 266 |
} |
| 267 | 267 |
} |
| ... | ... |
@@ -297,7 +297,7 @@ Function Validate-GoFormat($headCommit, $upstreamCommit) {
|
| 297 | 297 |
Write-Host 'Congratulations! All Go source files are properly formatted.' |
| 298 | 298 |
} else {
|
| 299 | 299 |
$e = "`nThese files are not properly gofmt`'d:`n" |
| 300 |
- $badFiles | %{ $e+=" - $_`n"}
|
|
| 300 |
+ $badFiles | ForEach-Object{ $e+=" - $_`n"}
|
|
| 301 | 301 |
$e+= "`nPlease reformat the above files using `"gofmt -s -w`" and commit the result." |
| 302 | 302 |
Throw $e |
| 303 | 303 |
} |
| ... | ... |
@@ -55,7 +55,7 @@ const ( |
| 55 | 55 |
' |
| 56 | 56 |
|
| 57 | 57 |
# Write the file without BOM |
| 58 |
- $outputFile="$(pwd)\dockerversion\version_autogen.go" |
|
| 58 |
+ $outputFile="$(Get-Location)\dockerversion\version_autogen.go" |
|
| 59 | 59 |
if (Test-Path $outputFile) { Remove-Item $outputFile }
|
| 60 | 60 |
[System.IO.File]::WriteAllText($outputFile, $fileContents, (New-Object System.Text.UTF8Encoding($False))) |
| 61 | 61 |
|