deadc0de6 / dotdrop

Save your dotfiles once, deploy them everywhere
https://dotdrop.readthedocs.io
GNU General Public License v3.0
1.77k stars 105 forks source link

[bug] Directory ignore pattern not working in cmpignore #431

Closed ckudera closed 6 months ago

ckudera commented 7 months ago

Dotdrop version (and git commit if run from source): de05935ef1efa1bde32dbcbc80a46487dd825a8c (Sun Dec 31 14:14:00 2023 +0100) Using dotdrop: as a submodule

Describe the bug

Similar to #418, directories are not ignored.

Steps to Reproduce

~/.config/obsidian directory structure:

.rw-r--r--. fedora fedora  90 B  Fri Jan 19 00:51:04 2024  1853510a538d0a01.json
drwx------. fedora fedora  72 B  Fri Jan 19 08:57:15 2024  blob_storage
drwx------. fedora fedora  20 B  Tue Dec 19 16:27:02 2023  Cache
drwx------. fedora fedora  12 B  Tue Dec 19 16:27:02 2023  'Code Cache'
.rw-------. fedora fedora  20 KB Tue Jan 16 22:28:22 2024  Cookies
.rw-------. fedora fedora   0 B  Tue Jan 16 22:28:22 2024  Cookies-journal
drwx------. fedora fedora  18 B  Tue Dec 19 16:27:02 2023  Crashpad
.rw-------. fedora fedora  83 B  Fri Jan 19 12:55:17 2024  'Custom Dictionary.txt'
.rw-------. fedora fedora  78 B  Fri Jan 19 12:55:17 2024  'Custom Dictionary.txt.backup'
drwx------. fedora fedora  64 B  Tue Dec 19 16:30:14 2023  databases
drwx------. fedora fedora  58 B  Tue Dec 19 16:27:02 2023  DawnCache
drwx------. fedora fedora  58 B  Fri Jan 19 12:29:29 2024  Dictionaries
drwx------. fedora fedora  58 B  Tue Dec 19 16:27:02 2023  GPUCache
.rw-r--r--. fedora fedora  32 B  Tue Dec 19 16:27:02 2023  id
drwx------. fedora fedora 316 B  Mon Jan 15 16:49:54 2024  IndexedDB
drwx------. fedora fedora  14 B  Tue Dec 19 16:27:02 2023  'Local Storage'
.rw-------. fedora fedora 3.5 KB Fri Jan 19 12:30:35 2024  'Network Persistent State'
drwxr-xr-x. fedora fedora 238 B  Mon Jan  1 23:47:03 2024  'Obsidian Sandbox'
.rw-r--r--. fedora fedora 112 B  Fri Jan 19 08:57:15 2024  obsidian.json
.rw-r--r--. fedora fedora  50 KB Fri Jan 19 12:57:14 2024  obsidian.log
.rw-------. fedora fedora 102 B  Fri Jan 19 12:29:35 2024  Preferences
drwx------. fedora fedora  24 B  Sun Jan  7 23:47:01 2024  'Service Worker'
drwx------. fedora fedora  92 B  Fri Jan 19 00:51:04 2024  'Session Storage'
drwx------. fedora fedora  94 B  Mon Jan 15 16:38:35 2024  shared_proto_db
lrwxrwxrwx. fedora fedora  20 B  Fri Jan 19 08:57:14 2024  SingletonCookie ⇒ 12504177748253744310
lrwxrwxrwx. fedora fedora  12 B  Fri Jan 19 08:57:14 2024  SingletonLock ⇒ desktop-4909
lrwxrwxrwx. fedora fedora  37 B  Fri Jan 19 08:57:14 2024  SingletonSocket ⇒ /tmp/scoped_dirgWC2Tt/SingletonSocket
.rw-------. fedora fedora 1.7 KB Thu Jan 18 23:41:06 2024  TransportSecurity
drwx------. fedora fedora  14 B  Mon Jan 15 16:38:35 2024  VideoDecodeStats
drwx------. fedora fedora  64 B  Mon Jan  8 15:09:47 2024  WebStorage

I tried different configurations (the first one as documented in the documentation):

  d_obsidian:
    src: config/obsidian
    dst: ~/.config/obsidian
    chmod: '700'
    cmpignore:
    - '!Custom Dictionary.txt'
    - '[a-zA-Z0-9]*'
  d_obsidian:
    src: config/obsidian
    dst: ~/.config/obsidian
    chmod: '700'
    cmpignore:
    - '!Custom Dictionary.txt'
    - '[a-zA-Z0-9\ ]*'
  d_obsidian:
    src: config/obsidian
    dst: ~/.config/obsidian
    chmod: '700'
    cmpignore:
    - "*"
    - '!Custom Dictionary.txt'

But the output of dotdrop compare is always:

=> compare d_obsidian: diffing with "/home/fedora/.config/obsidian"
=> "Cache" does not exist in dotdrop
=> "Code Cache" does not exist in dotdrop
=> "Crashpad" does not exist in dotdrop
=> "DawnCache" does not exist in dotdrop
=> "Dictionaries" does not exist in dotdrop
=> "GPUCache" does not exist in dotdrop
=> "IndexedDB" does not exist in dotdrop
=> "Local Storage" does not exist in dotdrop
=> "Obsidian Sandbox" does not exist in dotdrop
=> "Service Worker" does not exist in dotdrop
=> "Session Storage" does not exist in dotdrop
=> "SingletonCookie" does not exist in dotdrop
=> "SingletonLock" does not exist in dotdrop
=> "VideoDecodeStats" does not exist in dotdrop
=> "WebStorage" does not exist in dotdrop
=> "blob_storage" does not exist in dotdrop
=> "databases" does not exist in dotdrop
=> "shared_proto_db" does not exist in dotdrop
=> diff "Custom Dictionary.txt":
--- "/home/fedora/.config/obsidian/Custom Dictionary.txt"   2024-01-19 12:55:17.867850670 +0100
+++ "/home/fedora/Backup/dotfiles/dotfiles/config/obsidian/Custom Dictionary.txt"   2024-01-19 12:44:53.227059955 +0100
@@ -1,4 +1,3 @@
 Bachelorarbeit
 Bachelorarbeiten
-Repo
-checksum_v1 = 142cd40b49ff25cede960e0ebd480ed3
\ No newline at end of file
+checksum_v1 = f470ae77284243a7408904721d472d18
\ No newline at end of file

Therefore, files are ignored, but directories are not.

Expected behavior

Every file and directory except Custom Dictionary.txt should be ignored.

Additional information

I know, I could simply backup only the Custom Dictionary.txt file, but I might want to add files from the /home/fedora/.config/obsidian/ directory in the future.

Dotdrop's execution with the debug logs (--verbose) output.txt

deadc0de6 commented 7 months ago

Thanks for reporting this and sorry for the late reply. I will look at that ASAP and will get back to you.

ckudera commented 7 months ago

@deadc0de6 Thank you for the fast fix and your amazing work on dotdrop :)

deadc0de6 commented 6 months ago

@ckudera I have completely refactored the way the ignore pattern (and negative ignore pattern) are handled in dotdrop. That should fix your issue above. Could you give it a try in the branch fix-431? Here's the doc on how to use the branch with dotdrop. Thanks!

ckudera commented 6 months ago

@deadc0de6 Yes, it works :) Thank you!

deadc0de6 commented 6 months ago

@ckudera the new feature is available in the master branch. Thanks for your help on this :+1: