purescript / spago

🍝 PureScript package manager and build tool
BSD 3-Clause "New" or "Revised" License
792 stars 132 forks source link

Faster globbing by respecting root .gitignore. #1209

Closed Blugatroff closed 8 months ago

Blugatroff commented 8 months ago

Addresses part of #1182 by implementing this snippet.

I'm not sure, whether this is the right place for the change, would it have been better to implement this purescript/registry-dev since that's where Glob.match' is implemented? Although then again, Glob.match' is just a wrapper for fast-glob.

On my laptop and repo mentioned in #1182 this change reduces the time spent globbing for spago.yaml from 600ms to 30ms :)

Description of the change

Instead of globbing everything for **/spago.yaml and then filtering the matches against .gitignore files, use every entry in the root .gitignore as a negative match (ignore) while globbing.

The resulting matches still need to be checked seperately using Git.isIgnored, because the new function only considers the root .gitignore file, .gitignore files in subdirectories are ignored.

Checklist: