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

New feature: Negative ignore patterns #298

Merged
merged 19 commits into from
Dec 31, 2020

Conversation

jtt9340
Copy link
Contributor

@jtt9340 jtt9340 commented Dec 31, 2020

This PR adds a feature that I felt was missing in dotdrop, so I decided to try implementing this feature myself. I'm calling it "negative ignore patterns," and it basically allows you to prepend !s to ignore patterns to "un-ignore" any previously-ignored files, similar to how !s work in .gitignore files. In other words, if a file matches a negative-ignore pattern, and it previously matched a (normal) ignore pattern, then that file will not be ignored.

My motivation for wanting this feature was, at first, wanting to ignore every file in a certain directory, $ZDOTDIR/zfunc, except one, $ZDOTDIR/zfunc/_python-workon-cwd. Without the negative-ignore-patterns feature I would have to include an ignore pattern for every file in $ZDOTDIR/zfunc except for $ZDOTDIR/zfunc/_python-workon-cwd, and if I ever added any more files to $ZDOTDIR/zfunc, I would have to remember to add the ignore pattern for them too. With the negative-ignore-patterns feature, I would be able to add a blanket ignore pattern, */zfunc/*, and then add the negative-ignore pattern !*/zfunc/_python-workon-cwd after that to instruct dotdrop to ignore everything in any directory called zfunc except for _python-workon-cwd.

I tried to find all the places where there is logic for matching ignore patterns to add this feature. Additionally, I have added several Bash script unit tests in the tests-ng directory.

Hopefully this feature is useful and thank you for making dotdrop!

jtt9340 and others added 19 commits December 14, 2020 18:58
On macOS, creating a temporary directory creates a hard link to a file with a different name, which causes dotdrop to think it is importing a symlink. This causes the unit tests to fail as dotdrop attempts to ask the user if it should dereference the symlink, but dotdrop is not connected to stdin when the shell script tests are running so dotdrop crashes with an EOFError. The solution is to pass the -f flag when invoking `dotdrop import` in tests.
Accidentally used a hard tab instead of spaces when indenting a YAML code snippet
@coveralls
Copy link

coveralls commented Dec 31, 2020

Coverage Status

Coverage increased (+0.2%) to 86.453% when pulling a93d475 on jtt9340:negative-ignore-patterns into 636c1ad on deadc0de6:master.

@deadc0de6
Copy link
Owner

Very nice, thanks a lot for your contribution! Awesome job 👍

@deadc0de6 deadc0de6 merged commit 39d52a2 into deadc0de6:master Dec 31, 2020
@jtt9340 jtt9340 deleted the negative-ignore-patterns branch July 22, 2023 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants