From f737c5d3410e88524d18e26c633c89e2d495832a Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 26 Sep 2022 14:45:33 +0200 Subject: [PATCH 1/2] update-vendor.sh: handle empty staging repo A staging repo which just got created with only the doc.go file in it won't have any dependencies yet, which caused the script to fail because the dependency files didn't get created: +++ [0926 14:33:22] go.mod: tidying cat: /tmp/update-vendor.1VTv/group_replace.ZbIT/go.mod.require_direct.tmp: No such file or directory !!! [0926 14:33:23] Call tree: !!! [0926 14:33:23] 1: hack/update-vendor.sh:354 group_directives(...) --- hack/update-vendor.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/hack/update-vendor.sh b/hack/update-vendor.sh index 0f0fe47af77..5b35ef7cfb1 100755 --- a/hack/update-vendor.sh +++ b/hack/update-vendor.sh @@ -114,6 +114,17 @@ function ensure_require_replace_directives_for_all_dependencies() { | xargs -L 100 go mod edit -fmt } +function print_go_mod_section() { + local directive="$1" + local file="$2" + + if [ -s "${file}" ]; then + echo "${directive} (" + cat "$file" + echo ")" + fi +} + function group_directives() { local local_tmp_dir local_tmp_dir=$(mktemp -d "${TMP_DIR}/group_replace.XXXX") @@ -146,15 +157,9 @@ function group_directives() { " < go.mod { cat "${go_mod_other}"; - echo "require ("; - cat "${go_mod_require_direct}"; - echo ")"; - echo "require ("; - cat "${go_mod_require_indirect}"; - echo ")"; - echo "replace ("; - cat "${go_mod_replace}"; - echo ")"; + print_go_mod_section "require" "${go_mod_require_direct}" + print_go_mod_section "require" "${go_mod_require_indirect}" + print_go_mod_section "replace" "${go_mod_replace}" } > go.mod go mod edit -fmt From 9b5e9d8978f03907d054f252e1fed6c895d44c33 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 4 Oct 2022 12:39:05 +0200 Subject: [PATCH 2/2] update-vendor.sh: add reminder about LICENSE files The script might have added or removed LICENSE files. Those changes also need to be added manually to a commit. --- hack/update-vendor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/update-vendor.sh b/hack/update-vendor.sh index 5b35ef7cfb1..71f5673bcf7 100755 --- a/hack/update-vendor.sh +++ b/hack/update-vendor.sh @@ -425,4 +425,4 @@ reviewers: - dep-reviewers __EOF__ -kube::log::status "NOTE: don't forget to handle vendor/* files that were added or removed" +kube::log::status "NOTE: don't forget to handle vendor/* and LICENSE/* files that were added or removed"