From 7dd25dd763a87923287e5963bb002460be58d908 Mon Sep 17 00:00:00 2001 From: Camilo Sanchez Date: Tue, 14 Apr 2026 16:30:35 -0700 Subject: [PATCH] Fix wt-metadata-refresh failing on .bazelproject with commented directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs caused metadata refresh to always fail: 1. The awk regex for parsing .bazelproject commented lines (e.g. ' # ca') didn't actually filter them out — [^#] matched the second space char, so invalid paths like '//# ca/...' leaked into the bazel query. 2. set -o pipefail + piping bazel query into sort meant any non-zero exit from bazel query (e.g. 'no targets found beneath .hooks') killed the whole pipeline before the exit code could be captured. Fix: strip whitespace first then check for '#' prefix, use --keep_going to tolerate missing targets, and || true to avoid pipefail issues. Co-authored-by: Amp Amp-Thread-ID: https://ampcode.com/threads/T-019d8e51-8b94-7615-a478-c7aa9b77f49c --- lib/wt-metadata-refresh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/wt-metadata-refresh b/lib/wt-metadata-refresh index 6e1fd65..9695c45 100755 --- a/lib/wt-metadata-refresh +++ b/lib/wt-metadata-refresh @@ -188,7 +188,7 @@ parse_bazelproject_directories() { awk ' /^directories:/ { in_dirs=1; next } /^[a-z_]+:/ { in_dirs=0 } - in_dirs && /^[[:space:]]+[^#]/ { gsub(/^[[:space:]]+/, ""); print } + in_dirs { gsub(/^[[:space:]]+/, ""); if ($0 != "" && !/^#/) print } ' "$bazelproject_file" } @@ -281,17 +281,10 @@ refresh_targets_file() { # Run bazel query from the MAIN REPO ROOT (not project root) # This is important because .bazelproject directories are relative to repo root local query_output - local query_exit_code=0 - query_output=$( cd "$WT_MAIN_REPO_ROOT" 2>/dev/null && \ - bazel query "$full_query" --output=label 2>/dev/null | sort - ) || query_exit_code=$? - - if [[ $query_exit_code -ne 0 ]]; then - warn " Bazel query failed for $project_name (exit code: $query_exit_code)" - return 1 - fi + { bazel query "$full_query" --output=label --keep_going 2>/dev/null || true; } | sort + ) if [[ -z "$query_output" ]]; then warn " Bazel query returned empty results for $project_name"