Skip to content

Commit 1547929

Browse files
committed
more pr suggestions
1 parent bfceb4c commit 1547929

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

scripts/check_go_version.sh

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,15 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
fix=0
5-
args="$(getopt -o "" -l fix -- "$@")"
6-
eval set -- "$args"
7-
while true; do
8-
case "$1" in
9-
--fix)
10-
fix=1
11-
shift
12-
;;
13-
--)
14-
shift
15-
break
16-
;;
17-
*)
18-
error "Unrecognized option: $1"
19-
;;
20-
esac
21-
done
22-
234
MOD_VERSION=$(go mod edit -json | jq -r .Go)
245
echo "go.mod version: $MOD_VERSION"
256
STATUS=0
267

27-
if [[ $fix -eq 1 ]]; then
8+
if [[ " $* " == *" --fix "* ]]; then
289
for wf in .github/workflows/*.{yml,yaml}; do
2910
sed -i "s/go-version:.*/go-version: \"${MOD_VERSION}\"/g" "${wf}"
3011
done
31-
exit $STATUS
12+
exit 0
3213
fi
3314

3415
for wf in .github/workflows/*.{yml,yaml}; do
@@ -37,9 +18,9 @@ for wf in .github/workflows/*.{yml,yaml}; do
3718
continue
3819
fi
3920

40-
UNIQUE_WF_VERSIONS=$(echo "$WF_VERSIONS" | sort -u)
21+
UNIQUE_WF_VERSIONS=$(sort -u <<<"$WF_VERSIONS")
4122
for ver in $UNIQUE_WF_VERSIONS; do
42-
if [[ "${ver}" != "$MOD_VERSION" ]]; then
23+
if [[ $ver != "$MOD_VERSION" ]]; then
4324
STATUS=1
4425
echo "$wf: go.mod=$MOD_VERSION but workflow uses $(tr '\n' ' ' <<<"$UNIQUE_WF_VERSIONS")"
4526
continue

0 commit comments

Comments
 (0)