Skip to content

Commit

Permalink
test: fix presubmit script to handle dirs (googleapis#10185)
Browse files Browse the repository at this point in the history
It seems googleapis#10064 changed the semantics from files to dirs for significant changes. This caused `CHANGED_DIRS` to fail when the grep test was done as sometimes there is no slash now. This piping was not actually needed though and the cut should work even if the character is not there.

This failure to grep caused presubmits to run for whole repo sometimes when changes were only made in one sub-module.
  • Loading branch information
codyoss committed May 15, 2024
1 parent 75e8fd0 commit 78c53a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/kokoro/presubmit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fi

# CHANGED_DIRS is the list of significant top-level directories that changed,
# but weren't deleted by the current PR. CHANGED_DIRS will be empty when run on main.
CHANGED_DIRS=$(echo "$SIGNIFICANT_CHANGES" | tr ' ' '\n' | grep "/" | cut -d/ -f1 | sort -u |
CHANGED_DIRS=$(echo "$SIGNIFICANT_CHANGES" | tr ' ' '\n' | cut -d/ -f1 | sort -u |
tr '\n' ' ' | xargs ls -d 2>/dev/null || true)

echo "Running tests only in changed submodules: $CHANGED_DIRS"
Expand Down

0 comments on commit 78c53a3

Please sign in to comment.