mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 19:09:44 +00:00
fix ignores
This commit is contained in:
@@ -233,6 +233,7 @@ def must_ignore(paths, ignores, debug=False):
|
|||||||
lambda ign: ign.startswith('!'), ignores)
|
lambda ign: ign.startswith('!'), ignores)
|
||||||
for path in paths:
|
for path in paths:
|
||||||
ignore_matches = []
|
ignore_matches = []
|
||||||
|
isdir = os.path.isdir(path)
|
||||||
# First ignore dotfiles
|
# First ignore dotfiles
|
||||||
for i in ignored:
|
for i in ignored:
|
||||||
if fnmatch.fnmatch(path, i):
|
if fnmatch.fnmatch(path, i):
|
||||||
@@ -263,12 +264,25 @@ def must_ignore(paths, ignores, debug=False):
|
|||||||
warn += 'that is being ignored by a '
|
warn += 'that is being ignored by a '
|
||||||
warn += 'previous ignore pattern.'
|
warn += 'previous ignore pattern.'
|
||||||
LOG.warn(warn)
|
LOG.warn(warn)
|
||||||
|
else:
|
||||||
|
if debug:
|
||||||
|
msg = f'negative ignore \"{nign}\" NO match: {path}'
|
||||||
|
LOG.dbg(msg, force=True)
|
||||||
if ignore_matches:
|
if ignore_matches:
|
||||||
if debug:
|
if debug:
|
||||||
LOG.dbg(f'ignoring {paths}', force=True)
|
LOG.dbg(f'effectively ignoring \"{paths}\"', force=True)
|
||||||
|
if isdir and len(ignored_negative) > 0:
|
||||||
|
# this ensures whoever calls this function will
|
||||||
|
# descend into the directory to explore the possiblity
|
||||||
|
# of a file matching the non-ignore pattern
|
||||||
|
if debug:
|
||||||
|
msg = 'ignore would have match but neg ignores'
|
||||||
|
msg += f' present and is a dir: \"{path}\" -> not ignored!'
|
||||||
|
LOG.dbg(msg, force=True)
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
if debug:
|
if debug:
|
||||||
LOG.dbg(f'NOT ignoring {paths}', force=True)
|
LOG.dbg(f'NOT ignoring \"{paths}\"', force=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@@ -283,7 +297,7 @@ def uniq_list(a_list):
|
|||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
||||||
def ignores_to_absolute(ignores, prefix, debug=False):
|
def ignores_to_absolute(ignores, prefixes, debug=False):
|
||||||
"""allow relative ignore pattern"""
|
"""allow relative ignore pattern"""
|
||||||
new = []
|
new = []
|
||||||
LOG.dbg(f'ignores before patching: {ignores}', force=debug)
|
LOG.dbg(f'ignores before patching: {ignores}', force=debug)
|
||||||
@@ -308,11 +322,12 @@ def ignores_to_absolute(ignores, prefix, debug=False):
|
|||||||
new.append(ignore)
|
new.append(ignore)
|
||||||
continue
|
continue
|
||||||
# patch ignore
|
# patch ignore
|
||||||
path = os.path.join(prefix, ignore)
|
for prefix in prefixes:
|
||||||
if negative:
|
path = os.path.join(prefix, ignore)
|
||||||
new.append('!' + path)
|
if negative:
|
||||||
else:
|
new.append('!' + path)
|
||||||
new.append(path)
|
else:
|
||||||
|
new.append(path)
|
||||||
LOG.dbg(f'ignores after patching: {new}', force=debug)
|
LOG.dbg(f'ignores after patching: {new}', force=debug)
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user