tbh I thought that the code already did this. Turns out I'd just thought about it, not implemented it.
Pre-PR, the tool uses the slow but thorough approach of calling git ls-filesfor each individual pattern to find which files match that pattern. Thus the runtime scales with the number of CODEOWNERS lines. Zendesk help-center currently has > 1000 lines of CODEOWNERS, which means > 1000 calls to git ls-files, which makes this tool slow (> 10 seconds runtime).
For the more complex patterns (e.g. those involving *), calling git ls-files is a reasonable approach. But for some patterns – the vast majority of help-center's entries – a much simpler, faster approach can be used:
for patterns starting and ending with /, and not containing * ? [ (example: /app/controllers/), we can use a simple string-prefix match against the list of all files in the repo
for patterns starting but not ending with /, and not containing * ? [ (example: /app/controllers/my_controller.rb), we can use a single-entry-exact-match against the list of files
Everything else, we still send to git ls-files for detailed checking.
In help-center this means that the list of calls to git drops by about a factor of 10, and the runtime drops accordingly, down to about 1.7 seconds.
No test changes, since this is a non-functional change.
tbh I thought that the code already did this. Turns out I'd just thought about it, not implemented it.
Pre-PR, the tool uses the slow but thorough approach of calling
git ls-files
for each individual pattern to find which files match that pattern. Thus the runtime scales with the number of CODEOWNERS lines. Zendesk help-center currently has > 1000 lines of CODEOWNERS, which means > 1000 calls togit ls-files
, which makes this tool slow (> 10 seconds runtime).For the more complex patterns (e.g. those involving
*
), callinggit ls-files
is a reasonable approach. But for some patterns – the vast majority of help-center's entries – a much simpler, faster approach can be used:/
, and not containing* ? [
(example:/app/controllers/
), we can use a simple string-prefix match against the list of all files in the repo/
, and not containing* ? [
(example:/app/controllers/my_controller.rb
), we can use a single-entry-exact-match against the list of filesEverything else, we still send to
git ls-files
for detailed checking.In
help-center
this means that the list of calls togit
drops by about a factor of 10, and the runtime drops accordingly, down to about 1.7 seconds.No test changes, since this is a non-functional change.