Skip to content

Commit

Permalink
Trim last slash when pruning paths
Browse files Browse the repository at this point in the history
The check for unit tests looks for directories to exclude, and
removes the first slash. The purpose of this removal is to trim the
slash at the end of a path, as output by git ls-files, because paths
with a trailing slash don't match when used in find's -path check.
The current code works as long as the directories being removed are at
the top level; if not, a slash in the middle is trimmed, and the path
would fail anyway (and find warns about this).

Trimming the last slash in all cases avoids the various issues here.

Signed-off-by: Stephen Kitt <[email protected]>
  • Loading branch information
skitt authored and tpantelis committed Mar 19, 2024
1 parent f8be156 commit 09008ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/shared/unit_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source "${SCRIPTS_DIR}/lib/debug_functions"
function _find() {
declare -a excludes
for entry in .git $(git ls-files -o -i --exclude-from=.gitignore --directory); do
test -f "$entry" || excludes+=(-path "./${entry/\/}" -prune -o)
test -f "$entry" || excludes+=(-path "./${entry/%\/}" -prune -o)
done

find . "${excludes[@]}" "$@" -printf "%h\0" | sort -z -u
Expand Down

0 comments on commit 09008ca

Please sign in to comment.