MCPcopy
hub / github.com/GitGuardian/ggshield / is_gitignored

Function is_gitignored

ggshield/utils/git_shell.py:492–503  ·  view source on GitHub ↗

Returns True if the path is ignored by git, False if it is not, or None if git is not available or the directory is not a git repository. :param path: path to the file or directory to check

(path: Path)

Source from the content-addressed store, hash-verified

490
491
492def is_gitignored(path: Path) -> Optional[bool]:
493 """
494 Returns True if the path is ignored by git, False if it is not,
495 or None if git is not available or the directory is not a git repository.
496 :param path: path to the file or directory to check
497 """
498 working_dir = Path.cwd()
499 if not is_git_available() or not is_git_dir(working_dir):
500 return None
501 else:
502 res = git(["check-ignore", "--", path.as_posix()], cwd=working_dir, check=False)
503 return res == path.as_posix()
504
505
506def gitignore(path: Path):

Calls 3

is_git_availableFunction · 0.85
is_git_dirFunction · 0.85
gitFunction · 0.85