Skip to content

Commit 00890aa

Browse files
pjjwalexeagle
authored andcommitted
fix filename pattern matching
git ls-files seems to match against filename strings exactly, and doesn't use the same logic as e.g. gitignore. this means that to match files by exact filename below the root, we need a */ at the start of the pattern to match more than files strictly at the root of the tree. these prefixed patterns however miss the root, so we need to include both forms. this is doable with bash array regexes to avoid changing the pattern format to work with both find and git ls-files at the same time.
1 parent 15fcab9 commit 00890aa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

format/private/format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function ls-files {
6262

6363
# TODO: determine which staged changes we should format; avoid formatting unstaged changes
6464
# TODO: try to format only modified regions of the file (where supported)
65-
git ls-files --cached --modified --other --exclude-standard ${patterns[@]} | {
65+
git ls-files --cached --modified --other --exclude-standard "${patterns[@]}" "${patterns[@]/#/*/}" | {
6666
grep -vE "^$(git ls-files --deleted)$" || true;
6767
}
6868
else

0 commit comments

Comments
 (0)