poetry2nix icon indicating copy to clipboard operation
poetry2nix copied to clipboard

Fix infinite recursion if .git directory doesn't exist

Open TSRBerry opened this issue 11 months ago • 0 comments

This cost me a few hours yesterday when I was trying to figure out why my flake wasn't working anymore. Turns out all the files and directories of my gitignore (including the .git directory) were already filtered out by the time findGitIgnores runs.

This shouldn't be a problem as long as it eventually aborts, but that wasn't the case. Since each iteration adds another /.. to the path it can't ever be equal to / which causes the function to recurse forever.

By using dirOf instead of appending /.. we can avoid this issue and make sure this function always aborts at some point.

I'd like to add some tests for this, but I have no idea how to do that as I'm still new to Nix. Could you help me with that?


Contribution checklist (recommended but not always applicable/required):

  • [ ] There's an automated test for this change
  • [x] Commit messages or code include references to related issues or PRs (including third parties)
  • [x] Commit messages are conventional - examples from the log include "feat: add changelog files to fixup hook", "fix(contourpy): allow wheel usage", and "test: add sqlalchemy2 test"

TSRBerry avatar Mar 09 '24 19:03 TSRBerry