mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 01:44:16 +00:00
strict ignore for compare
This commit is contained in:
@@ -35,7 +35,7 @@ class FTreeDir:
|
|||||||
for file in files:
|
for file in files:
|
||||||
fpath = os.path.join(root, file)
|
fpath = os.path.join(root, file)
|
||||||
if must_ignore([fpath], ignores=self.ignores,
|
if must_ignore([fpath], ignores=self.ignores,
|
||||||
debug=self.debug):
|
debug=self.debug, strict=True):
|
||||||
continue
|
continue
|
||||||
self.entries.append(fpath)
|
self.entries.append(fpath)
|
||||||
for dname in dirs:
|
for dname in dirs:
|
||||||
@@ -44,7 +44,7 @@ class FTreeDir:
|
|||||||
# ignore empty directory
|
# ignore empty directory
|
||||||
continue
|
continue
|
||||||
if must_ignore([dpath], ignores=self.ignores,
|
if must_ignore([dpath], ignores=self.ignores,
|
||||||
debug=self.debug):
|
debug=self.debug, strict=True):
|
||||||
continue
|
continue
|
||||||
self.entries.append(dpath)
|
self.entries.append(dpath)
|
||||||
|
|
||||||
|
|||||||
@@ -249,7 +249,8 @@ def _match_ignore_pattern(path, pattern, debug=False):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _must_ignore(path, ignores, neg_ignores, debug=False):
|
def _must_ignore(path, ignores, neg_ignores,
|
||||||
|
debug=False, strict=False):
|
||||||
"""
|
"""
|
||||||
return true if path matches any ignore patterns
|
return true if path matches any ignore patterns
|
||||||
"""
|
"""
|
||||||
@@ -298,7 +299,7 @@ def _must_ignore(path, ignores, neg_ignores, debug=False):
|
|||||||
# if debug:
|
# if debug:
|
||||||
# LOG.dbg(f'NOT ignoring \"{path}\"', force=True)
|
# LOG.dbg(f'NOT ignoring \"{path}\"', force=True)
|
||||||
return False
|
return False
|
||||||
if (
|
if not strict and (
|
||||||
os.path.isdir(path) or not os.path.exists(path)
|
os.path.isdir(path) or not os.path.exists(path)
|
||||||
) and neg_ignore_cnt > 0:
|
) and neg_ignore_cnt > 0:
|
||||||
# this ensures whoever calls this function will
|
# this ensures whoever calls this function will
|
||||||
@@ -315,7 +316,8 @@ def _must_ignore(path, ignores, neg_ignores, debug=False):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def must_ignore(paths, ignores, debug=False):
|
def must_ignore(paths, ignores, debug=False,
|
||||||
|
strict=False):
|
||||||
"""
|
"""
|
||||||
return true if any paths in list matches any ignore patterns
|
return true if any paths in list matches any ignore patterns
|
||||||
"""
|
"""
|
||||||
@@ -327,7 +329,8 @@ def must_ignore(paths, ignores, debug=False):
|
|||||||
nign, ign = categorize(
|
nign, ign = categorize(
|
||||||
lambda ign: ign.startswith('!'), ignores)
|
lambda ign: ign.startswith('!'), ignores)
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if _must_ignore(path, ign, nign, debug=debug):
|
if _must_ignore(path, ign, nign,
|
||||||
|
debug=debug, strict=strict):
|
||||||
if debug:
|
if debug:
|
||||||
LOG.dbg(f'[IGN] IGNORING \"{paths}\"', force=True)
|
LOG.dbg(f'[IGN] IGNORING \"{paths}\"', force=True)
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user