mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 02:11:09 +00:00
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(...)
This commit is contained in:
parent
fd6ee0df76
commit
f737c5d341
@ -114,6 +114,17 @@ function ensure_require_replace_directives_for_all_dependencies() {
|
|||||||
| xargs -L 100 go mod edit -fmt
|
| 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() {
|
function group_directives() {
|
||||||
local local_tmp_dir
|
local local_tmp_dir
|
||||||
local_tmp_dir=$(mktemp -d "${TMP_DIR}/group_replace.XXXX")
|
local_tmp_dir=$(mktemp -d "${TMP_DIR}/group_replace.XXXX")
|
||||||
@ -146,15 +157,9 @@ function group_directives() {
|
|||||||
" < go.mod
|
" < go.mod
|
||||||
{
|
{
|
||||||
cat "${go_mod_other}";
|
cat "${go_mod_other}";
|
||||||
echo "require (";
|
print_go_mod_section "require" "${go_mod_require_direct}"
|
||||||
cat "${go_mod_require_direct}";
|
print_go_mod_section "require" "${go_mod_require_indirect}"
|
||||||
echo ")";
|
print_go_mod_section "replace" "${go_mod_replace}"
|
||||||
echo "require (";
|
|
||||||
cat "${go_mod_require_indirect}";
|
|
||||||
echo ")";
|
|
||||||
echo "replace (";
|
|
||||||
cat "${go_mod_replace}";
|
|
||||||
echo ")";
|
|
||||||
} > go.mod
|
} > go.mod
|
||||||
|
|
||||||
go mod edit -fmt
|
go mod edit -fmt
|
||||||
|
Loading…
Reference in New Issue
Block a user