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)
| 490 | |
| 491 | |
| 492 | def 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 | |
| 506 | def gitignore(path: Path): |