Fix powershell scripts (#615)

* add check_deps.ps1

* fix check_gofmt select-string regex pattern

* capitalize JoinPath

* fix typo

* fail check_deps.ps1 on error
This commit is contained in:
lpdyck
2018-09-01 03:59:55 -06:00
committed by marpio
parent a2a2d93a9e
commit c4417371ef
4 changed files with 20 additions and 3 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ Param(
[switch]$down
)
function execScript($name) {
$scriptsDir = "$(join-path scripts ps)"
$scriptsDir = "$(Join-Path scripts ps)"
& "$(Join-Path $scriptsDir $name)"
}
+1 -1
View File
@@ -14,7 +14,7 @@ set -xeuo pipefail
git remote set-branches --add origin master && git fetch
ChangedFiles=`git diff --name-only origin/master`
# in the casse that ChangedFiles contains go.mod or go.sum run go mod verify
# in the case that ChangedFiles contains go.mod or go.sum run go mod verify
case "$ChangedFiles" in
go.mod | go.sum)
go mod verify
+17
View File
@@ -0,0 +1,17 @@
# check_deps.ps1
# this script checks for changes to the files go.mod and go.sum
#
# this is intended to be used in your CI tests
#
# on encountering any changes for these files the script runs go mod verify
# to check for any conflicts in versions or digests
# which on any exit code > 0 would suggest that action should be taken
# before a pull request can be merged.
git remote set-branches --add origin master ; git fetch
$ChangedFiles=$(git diff --name-only origin/master)
# in the case that ChangedFiles contains go.mod or go.sum run go mod verify
$contains= $ChangedFiles | Select-String -Pattern "go.mod|go.sum"
if ($contains.length -gt 0) {
Write-Error $(go mod verify)
}
+1 -1
View File
@@ -1,6 +1,6 @@
# check_gofmt.ps1
# Fail if a .go file hasn't been formatted with gofmt
$GO_FILES = Get-ChildItem -Recurse -Filter *.go -Name | Select-String -Pattern $(Join-Path "vendor" | Join-Path -ChildPath "") -NotMatch
$GO_FILES = Get-ChildItem -Recurse -Filter *.go -Name | Select-String -Pattern $(Join-Path "vendor" -ChildPath ".*") -NotMatch
$out = & gofmt -s -l $GO_FILES
if ($out.length -gt 0) {
Write-Error $out