From 58a9bca8f616b908cbf5b8d66589823f406858d9 Mon Sep 17 00:00:00 2001 From: Vasiliy Vasilyuk Date: Tue, 6 Feb 2024 22:56:04 +0300 Subject: [PATCH] Refactor script to improve readability Removed Indirect filter, it is not necessary because the list of direct modules is prepared in advance. Split the GO_LIST_FORMAT_FOR_UPDATE variable into several lines, so it is easier to read and understand the meaning. Signed-off-by: Vasiliy Vasilyuk --- go-mod-bump.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/go-mod-bump.sh b/go-mod-bump.sh index 329f8f0..948dca3 100755 --- a/go-mod-bump.sh +++ b/go-mod-bump.sh @@ -39,14 +39,15 @@ GO_LIST_FORMAT_DIRECT='{{.Path}}{{if .Indirect}}{{end}}' readonly GO_LIST_FORMAT_DIRECT # shellcheck disable=SC2068 -DIRECT_MODULES=$(go list -f "$GO_LIST_FORMAT_DIRECT" -m $@ | grep -v '') +DIRECT_MODULES=$(go list -m -f "$GO_LIST_FORMAT_DIRECT" $@ | grep -v '') readonly DIRECT_MODULES -GO_LIST_FORMAT_FOR_UPDATE='{{.Path}}@{{.Version}}@{{if .Update}}{{.Update.Version}}{{else}}{{end}}{{if .Indirect}}{{end}}' +GO_LIST_FORMAT_FOR_UPDATE='{{.Path}}@{{.Version}}@{{if .Update}}{{.Update.Version}}{{end}}' +GO_LIST_FORMAT_FOR_UPDATE+='{{if not .Update}}{{end}}' # skip modules without updates. readonly GO_LIST_FORMAT_FOR_UPDATE # shellcheck disable=SC2086 -MODULES_FOR_UPDATE=$(go list -f "$GO_LIST_FORMAT_FOR_UPDATE" -m -u $DIRECT_MODULES | grep -v '') +MODULES_FOR_UPDATE=$(go list -m -u -f "$GO_LIST_FORMAT_FOR_UPDATE" $DIRECT_MODULES | grep -v '') readonly MODULES_FOR_UPDATE function update_module() {