boxo icon indicating copy to clipboard operation
boxo copied to clipboard

fix: recursive directory filtering in `ShouldExclude`

Open crackcomm opened this issue 2 years ago • 4 comments

Ensure ignore rule bar/ matches directories by appending /. Addresses issue where bar/ didn't catch directories. After this change, both bar and bar/ rules filter out the bar directory and its contents.

Note: This is required because git would skip empty directories and use full paths relative to repo. I'm not sure how much I could break the API but it's still just using file names as opposed to full relative paths for filtering which is not ideal.

crackcomm avatar Nov 23 '23 10:11 crackcomm

Thank you for submitting this PR! A maintainer will be here shortly to review it. We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the rest) and in its best form. Follow the code contribution guidelines if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment. Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on any missing things and potentially assigning a reviewer for high priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution. We are very grateful for your contribution!

welcome[bot] avatar Nov 23 '23 10:11 welcome[bot]

@crackcomm just to understand: you're saying the current implementation is not fully compatible with https://git-scm.com/docs/gitignore, correct?

Yes, this PR fixes:

frotz/ matches frotz and a/frotz that is a directory (all paths are relative from the .gitignore file)

Nevertheless even after this change it's not fully compatible. To be fully compatible, the paths have to be matched against a relative path, right now it's just a file name.

crackcomm avatar Nov 23 '23 16:11 crackcomm

@hacdias I can add the function to the mock, no problem but could you please guide me where to add the test?

I would also want to add another change (not sure if separate PR or should I change this one): do NOT add the hidden files when they match ignore rules even if filter.IncludeHidden is true. Do you think that is a reasonable change?

crackcomm avatar Nov 26 '23 02:11 crackcomm

@crackcomm as for adding a test, I think filter_test.go is the place to go.

Do you think that is a reasonable change?

I think so. To me, that sounds like something that should've already been happening. If it is explicitly ignored as per the file, IncludeHidden should not override it.

For me you can include it with this PR, but please keep the commits separate just in case.

hacdias avatar Nov 27 '23 08:11 hacdias

I've converted this into a bug report: https://github.com/ipfs/boxo/issues/648 Closing this one, as it does not fully fix, nor test. T Thank you for bringing this to our attention. (If you have time to work on this in the future, feel free to open a new PR (with tests).)

lidel avatar Jul 30 '24 17:07 lidel