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

[bug] Negative (non-ignore) patterns refuse to match anything #388

Closed
niraami opened this issue Apr 29, 2023 · 6 comments
Closed

[bug] Negative (non-ignore) patterns refuse to match anything #388

niraami opened this issue Apr 29, 2023 · 6 comments
Labels

Comments

@niraami
Copy link

niraami commented Apr 29, 2023

Dotdrop version: v1.13.0-1
Using dotdrop: dotdrop from AUR

Describe the bug

When using ignore patterns, I can't get the inverse ignore pattern working. Every time I add ignore for '*', all subsequent non-ignore patterns don't get applied.

Steps to Reproduce

Add the following kind of ignore pattern to a dotfile (my example is a Blender config directory):

d_blender_addons:
    src: config/blender
    dst: ~/.config/blender
    upignore:
    - '*'
    - '!*/addons/**'
    cmpignore:
    - '*'
    - '!*/addons/**'

Run dotdrop update --dry, you'll see the folders ignored (twice) anyways:

-> "d_blender_addons" ignored
-> "/home/niraami/.config/blender/3.0/scripts/addons" ignored
-> "/home/niraami/.config/blender/3.2/scripts/addons" ignored
-> "/home/niraami/.config/blender/3.3/scripts/addons" ignored
-> "/home/niraami/.config/blender/3.4/scripts/addons" ignored
-> "/home/niraami/.config/blender/3.4/scripts/sketchfab_cache" ignored
-> "/home/niraami/.config/blender/3.5/scripts/addons" ignored
-> "d_blender_addons" ignored

Expected behavior

Files that match the negative ignore pattern should not get ignored.

Additional information
I've tried all sorts of other patterns, and different folders, with and/or without globs in the patterns, single and double quotes, but could not get it to work.

Dotdrop's execution with the debug logs (--verbose) with the above config:

$ dotdrop update --dry
...
[DEBUG][dotdrop.dotdrop._dotfile_compare] comparing key:"d_blender_addons", src:"/home/niraami/.dotfiles/user/config/blender", dst:"/home/niraami/.config/blender", link:"nolink", template:True
[DEBUG][dotdrop.utils.patch_ignores] ignores before patching: ['*', '!*/addons/**', '*.dotdropbak']
[DEBUG][dotdrop.utils.patch_ignores] ignores after patching: ['*', '!*/addons/**', '*.dotdropbak']
[DEBUG][dotdrop.templategen.path_is_template] is template: /home/niraami/.dotfiles/user/config/blender
[DEBUG][dotdrop.utils.must_ignore] must ignore? "['/home/niraami/.dotfiles/user/config/blender']" against ['*', '!*/addons/**', '*.dotdropbak']
[DEBUG][dotdrop.utils.must_ignore] ignore "*" match: /home/niraami/.dotfiles/user/config/blender
[DEBUG][dotdrop.utils.must_ignore] trying to match :"/home/niraami/.dotfiles/user/config/blender" with non-ignore-pattern:"*/addons/**"
[DEBUG][dotdrop.utils.must_ignore] ignoring ['/home/niraami/.dotfiles/user/config/blender']
[DEBUG][dotdrop.comparator.compare] comparing /home/niraami/.dotfiles/user/config/blender and /home/niraami/.config/blender
[DEBUG][dotdrop.comparator.compare] ignore pattern(s): ['*', '!*/addons/**', '*.dotdropbak']
[DEBUG][dotdrop.comparator.compare] /home/niraami/.dotfiles/user/config/blender is a directory
[DEBUG][dotdrop.comparator._comp_dir] compare directory /home/niraami/.dotfiles/user/config/blender with /home/niraami/.config/blender
[DEBUG][dotdrop.utils.must_ignore] must ignore? "['/home/niraami/.dotfiles/user/config/blender', '/home/niraami/.config/blender']" against ['*', '!*/addons/**', '*.dotdropbak']
[DEBUG][dotdrop.utils.must_ignore] ignore "*" match: /home/niraami/.dotfiles/user/config/blender
[DEBUG][dotdrop.utils.must_ignore] trying to match :"/home/niraami/.dotfiles/user/config/blender" with non-ignore-pattern:"*/addons/**"
[DEBUG][dotdrop.utils.must_ignore] ignoring ['/home/niraami/.dotfiles/user/config/blender', '/home/niraami/.config/blender']
[DEBUG][dotdrop.comparator._comp_dir] ignoring diff /home/niraami/.dotfiles/user/config/blender and /home/niraami/.config/blender
[DEBUG][dotdrop.dotdrop._dotfile_compare] => compare d_blender_addons: diffing with "/home/niraami/.config/blender"
[DEBUG][dotdrop.dotdrop._dotfile_compare] same file
...

Relevant documentation is here.

@niraami niraami added the bug label Apr 29, 2023
@deadc0de6
Copy link
Owner

Thanks for reporting this, I was able to reproduce the bug and will investigate!

deadc0de6 added a commit that referenced this issue May 2, 2023
deadc0de6 added a commit that referenced this issue Jul 30, 2023
@niraami
Copy link
Author

niraami commented Aug 8, 2023

Hey, I'm glad to see you're still working on this, and I just wanted to mention that I appreciate it. Is there anything I could help with, like testing or small tasks - I don't have much free time, but I'm pretty well versed in Python.

@deadc0de6
Copy link
Owner

Hey, sure no problem. I must admit it was more complex than I expected and while searching to solve your issue, I found bugs in negative ignore spanning across other actions (install, compare, update, import).
Thanks a lot for your help, I will probably need you once I have something concrete for testing that's for sure. For now it's all good, I'll get there but I appreciate the help!

@deadc0de6
Copy link
Owner

@niraami I think I have something in the bug#388 branch. Could you test your use case using that branch?

Here is a little explanation on how to do the testing: https://dotdrop.readthedocs.io/en/latest/howto/test-latest-dotdrop/
You simply then need to switch to the bug#388 branch and point dotdrop.sh to your config file.

@niraami
Copy link
Author

niraami commented Aug 11, 2023

Yep, I'll test it as soon as I can.

deadc0de6 added a commit that referenced this issue Sep 4, 2023
deadc0de6 added a commit that referenced this issue Sep 7, 2023
@deadc0de6
Copy link
Owner

@niraami this was merged and is then available on the master branch. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants