mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-12 18:10:15 +00:00
support */dir1 pattern on ignore
This commit is contained in:
8
CONTRIBUTING.md
vendored
8
CONTRIBUTING.md
vendored
@@ -161,6 +161,14 @@ dynvariables:
|
|||||||
|
|
||||||
## Ignore pattern
|
## Ignore pattern
|
||||||
|
|
||||||
|
Officially only `*/file` and `*/dir/*` should be used for ignore pattern.
|
||||||
|
However we still recursively process each path components to ensure
|
||||||
|
that pattern like `*/dir` are matched (see `_match_ignore_pattern`
|
||||||
|
in `utils.py`).
|
||||||
|
|
||||||
|
We also append a separator to directory before checking
|
||||||
|
for a match with the ignore patterns.
|
||||||
|
|
||||||
**compare**
|
**compare**
|
||||||
|
|
||||||
* for files, match with ignore directly
|
* for files, match with ignore directly
|
||||||
|
|||||||
2
docs/config/config-file.md
vendored
2
docs/config/config-file.md
vendored
@@ -191,7 +191,7 @@ It is possible to ignore specific patterns when using dotdrop.
|
|||||||
* Using dotfiles block [upignore](config-dotfiles.md)
|
* Using dotfiles block [upignore](config-dotfiles.md)
|
||||||
* Using the command line switch `-i`/`--ignore`
|
* Using the command line switch `-i`/`--ignore`
|
||||||
|
|
||||||
The ignore pattern must follow Unix shell-style wildcards, like, for example `*/path/to/file` for files or
|
The ignore pattern must follow Unix shell-style wildcards, like for example `*/path/to/file` for files and
|
||||||
`*/path/to/directory/*` for directories.
|
`*/path/to/directory/*` for directories.
|
||||||
Make sure to quote these when using wildcards in the config file.
|
Make sure to quote these when using wildcards in the config file.
|
||||||
|
|
||||||
|
|||||||
@@ -227,15 +227,23 @@ def strip_home(path):
|
|||||||
def _match_ignore_pattern(path, pattern, debug=False):
|
def _match_ignore_pattern(path, pattern, debug=False):
|
||||||
"""
|
"""
|
||||||
returns true if path matches the pattern
|
returns true if path matches the pattern
|
||||||
|
we test the entire path but also
|
||||||
|
any parent directory recursively to
|
||||||
|
be able to match pattern like "*/dir"
|
||||||
"""
|
"""
|
||||||
if debug:
|
subpath = path
|
||||||
msg = f'fnmatch \"{path}\" against {pattern}'
|
while subpath != os.path.sep:
|
||||||
LOG.dbg(msg, force=True)
|
if debug:
|
||||||
ret = fnmatch.fnmatch(path, pattern)
|
msg = f'fnmatch \"{subpath}\" against {pattern}'
|
||||||
if debug:
|
LOG.dbg(msg, force=True)
|
||||||
LOG.dbg(f'ignore \"{pattern}\" match: {path}',
|
ret = fnmatch.fnmatch(subpath, pattern)
|
||||||
force=True)
|
if debug:
|
||||||
return ret
|
LOG.dbg(f'ignore \"{pattern}\" match: {subpath}',
|
||||||
|
force=True)
|
||||||
|
if ret:
|
||||||
|
return ret
|
||||||
|
subpath = os.path.dirname(subpath)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _must_ignore(path, ignores, neg_ignores, debug=False):
|
def _must_ignore(path, ignores, neg_ignores, debug=False):
|
||||||
|
|||||||
8
tests-ng/ignore-patterns.sh
vendored
8
tests-ng/ignore-patterns.sh
vendored
@@ -57,11 +57,11 @@ dotfiles:
|
|||||||
src: mpv
|
src: mpv
|
||||||
dst: ${tmpd}/mpv
|
dst: ${tmpd}/mpv
|
||||||
cmpignore:
|
cmpignore:
|
||||||
- '*/watch_later/*'
|
- '*/watch_later'
|
||||||
upignore:
|
upignore:
|
||||||
- '*/watch_later/*'
|
- '*/watch_later'
|
||||||
instignore:
|
instignore:
|
||||||
- '*/watch_later/*'
|
- '*/watch_later'
|
||||||
profiles:
|
profiles:
|
||||||
p1:
|
p1:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
@@ -97,7 +97,7 @@ config:
|
|||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
ignoreempty: true
|
ignoreempty: true
|
||||||
impignore:
|
impignore:
|
||||||
- '*/watch_later/*'
|
- '*/watch_later'
|
||||||
dotfiles:
|
dotfiles:
|
||||||
profiles:
|
profiles:
|
||||||
_EOF
|
_EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user