From 7de94d43cabc688f538072a9a8dbce726bde1670 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Thu, 28 Nov 2024 17:50:27 +0000 Subject: [PATCH] handle the case when modules are added or removed don't compare modules that didn't or doesn't exist --- hack/apidiff.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hack/apidiff.sh b/hack/apidiff.sh index 3fc6fe0e79a..6b67227caea 100755 --- a/hack/apidiff.sh +++ b/hack/apidiff.sh @@ -149,6 +149,10 @@ run () { out="$1" mkdir -p "$out" for d in "${targets[@]}"; do + if ! [ -d "${d}" ]; then + echo "module ${d} does not exist, skipping ..." + continue + fi # cd to the path for modules that are intree but not part of the go workspace # per example staging/src/k8s.io/code-generator/examples ( @@ -208,6 +212,10 @@ compare () { what="$1" before="$2" after="$3" + if [ ! -f "${before}" ] || [ ! -f "${after}" ]; then + echo "can not compare changes, module didn't exist before or after" + return + fi changes=$(apidiff -m "${before}" "${after}" 2>&1 | grep -v -e "^Ignoring internal package") || true echo "## ${what}" if [ -z "$changes" ]; then