Return True if Git ignore rules exclude a path.
(root: Path, rel: Path)
| 144 | |
| 145 | |
| 146 | def is_git_ignored(root: Path, rel: Path) -> bool: |
| 147 | """Return True if Git ignore rules exclude a path.""" |
| 148 | try: |
| 149 | result = subprocess.run( |
| 150 | ["git", "-C", str(root), "check-ignore", "-q", "--", str(rel)], |
| 151 | check=False, |
| 152 | stdout=subprocess.DEVNULL, |
| 153 | stderr=subprocess.DEVNULL, |
| 154 | ) |
| 155 | except OSError: |
| 156 | return False |
| 157 | return result.returncode == 0 |
| 158 | |
| 159 | |
| 160 | def is_dockerfile(path: Path) -> bool: |