811ca7153f
Sister project airshipctl is using this make target and supporting script and is very helpful to ensure dependencies are up to date and unused dependencies are removed. Adding to airshipui. Change-Id: Ic1ad3b134dbe871e489f851d41aea9bb3d25e9ba Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
24 lines
529 B
Bash
Executable File
24 lines
529 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
backup_dir=$(mktemp -d)
|
|
trap 'rm -rf "$backup_dir"' EXIT
|
|
|
|
revert() {
|
|
cp "$backup_dir/go.mod" "go.mod"
|
|
cp "$backup_dir/go.sum" "go.sum"
|
|
}
|
|
|
|
cp go.mod go.sum "$backup_dir"
|
|
if [[ $(go mod tidy 2>&1) ]]; then
|
|
printf "FAIL: error in go.mod. Please run 'go mod tidy' and fix any issues\n"
|
|
revert
|
|
exit 1
|
|
fi
|
|
|
|
if [[ $(diff "go.mod" "$backup_dir/go.mod") ]] || [[ $(diff "go.sum" "$backup_dir/go.sum") ]]; then
|
|
printf "FAIL: go.mod/go.sum are not up to date. Please run 'go mod tidy'\n"
|
|
revert
|
|
exit 1
|
|
fi
|