]>
git.madduck.net Git - etc/vim.git/blobdiff - src/black/files.py
madduck's git repository
Every one of the projects in this repository is available at the canonical
URL git://git.madduck.net/madduck/pub/<projectpath> — see
each project's metadata for the exact URL.
All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@ git. madduck. net .
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
SSH access, as well as push access can be individually
arranged .
If you use my repositories frequently, consider adding the following
snippet to ~/.gitconfig and using the third clone URL listed for each
project:
[url "git://git.madduck.net/madduck/"]
insteadOf = madduck:
return root_relative_path
return root_relative_path
-def path_is_ignored(
- path: Path, gitignore_dict: Dict[Path, PathSpec], report: Report
+def _path_is_ignored(
+ root_relative_path: str,
+ root: Path,
+ gitignore_dict: Dict[Path, PathSpec],
+ report: Report,
+ path = root / root_relative_path
+ # Note that this logic is sensitive to the ordering of gitignore_dict. Callers must
+ # ensure that gitignore_dict is ordered from least specific to most specific.
for gitignore_path, pattern in gitignore_dict.items():
for gitignore_path, pattern in gitignore_dict.items():
- relative_path = normalize_path_maybe_ignore(path, gitignore_path, report)
- if relative_path is None:
+ try:
+ relative_path = path.relative_to(gitignore_path).as_posix()
+ except ValueError:
break
if pattern.match_file(relative_path):
break
if pattern.match_file(relative_path):
- report.path_ignored(path, "matches a .gitignore file content")
+ report.path_ignored(
+ path.relative_to(root), "matches a .gitignore file content"
+ )
assert root.is_absolute(), f"INTERNAL ERROR: `root` must be absolute but is {root}"
for child in paths:
assert root.is_absolute(), f"INTERNAL ERROR: `root` must be absolute but is {root}"
for child in paths:
- normalized_path = normalize_path_maybe_ignore(child, root, report)
- if normalized_path is None:
- continue
+ root_relative_path = child.absolute().relative_to(root).as_posix()
# First ignore files matching .gitignore, if passed
# First ignore files matching .gitignore, if passed
- if gitignore_dict and path_is_ignored(child, gitignore_dict, report):
+ if gitignore_dict and _path_is_ignored(
+ root_relative_path, root, gitignore_dict, report
+ ):
continue
# Then ignore with `--exclude` `--extend-exclude` and `--force-exclude` options.
continue
# Then ignore with `--exclude` `--extend-exclude` and `--force-exclude` options.
- normalized_path = "/" + normalized _path
+ root_relative_path = "/" + root_relative _path
+ root_relative _path += "/"
- if path_is_excluded(normalized _path, exclude):
+ if path_is_excluded(root_relative _path, exclude):
report.path_ignored(child, "matches the --exclude regular expression")
continue
report.path_ignored(child, "matches the --exclude regular expression")
continue
- if path_is_excluded(normalized _path, extend_exclude):
+ if path_is_excluded(root_relative _path, extend_exclude):
report.path_ignored(
child, "matches the --extend-exclude regular expression"
)
continue
report.path_ignored(
child, "matches the --extend-exclude regular expression"
)
continue
- if path_is_excluded(normalized _path, force_exclude):
+ if path_is_excluded(root_relative _path, force_exclude):
report.path_ignored(child, "matches the --force-exclude regular expression")
continue
report.path_ignored(child, "matches the --force-exclude regular expression")
continue
+ normalized_path = normalize_path_maybe_ignore(child, root, report)
+ if normalized_path is None:
+ continue
+
if child.is_dir():
# If gitignore is None, gitignore usage is disabled, while a Falsey
# gitignore is when the directory doesn't have a .gitignore file.
if child.is_dir():
# If gitignore is None, gitignore usage is disabled, while a Falsey
# gitignore is when the directory doesn't have a .gitignore file.
elif child.is_file():
if child.suffix == ".ipynb" and not jupyter_dependencies_are_installed(
elif child.is_file():
if child.suffix == ".ipynb" and not jupyter_dependencies_are_installed(
- verbose=verbose, quiet= quiet
+ warn=verbose or not quiet
):
continue
include_match = include.search(normalized_path) if include else True
):
continue
include_match = include.search(normalized_path) if include else True