mirror of
https://github.com/gomods/athens
synced 2026-02-03 12:10:32 +00:00
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:
@@ -51,7 +51,7 @@ Param(
|
||||
[switch]$down
|
||||
)
|
||||
function execScript($name) {
|
||||
$scriptsDir = "$(join-path scripts ps)"
|
||||
$scriptsDir = "$(Join-Path scripts ps)"
|
||||
& "$(Join-Path $scriptsDir $name)"
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user