Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: recursive directory filtering in ShouldExclude #516

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

crackcomm
Copy link

@crackcomm crackcomm commented Nov 23, 2023

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 crackcomm requested a review from a team as a code owner November 23, 2023 10:15
Copy link

welcome bot commented Nov 23, 2023

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!

Copy link
Member

@hacdias hacdias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crackcomm just to understand: you're saying the current implementation is not fully compatible with https://git-scm.com/docs/gitignore, correct? If so, do you mind fixing the tests (adding the .IsDir method to the mock), as well as adding a regression test to ensure that this is working as expected?

@crackcomm
Copy link
Author

@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
Copy link
Author

@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?

@hacdias
Copy link
Member

hacdias commented Nov 27, 2023

@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.

@lidel lidel added the need/author-input Needs input from the original author label Dec 11, 2023
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.
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Triage notes:

@crackcomm are you able to address the above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/author-input Needs input from the original author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants