handle the case when modules are added or removed

don't compare modules that didn't or doesn't exist
This commit is contained in:
Antonio Ojea 2024-11-28 17:50:27 +00:00
parent 52386915a8
commit 7de94d43ca

View File

@ -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