Skip to content

Commit

Permalink
Prevent matching bogus parent gitignores
Browse files Browse the repository at this point in the history
If our project root directory is matched by an exclude pattern we
should assume the pattern is invalid as our project root is likely
in an ignored build directory of another project.
  • Loading branch information
jameshilliard committed Sep 6, 2024
1 parent 5352e44 commit 10d2308
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/src/hatchling/builders/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,11 @@ def load_vcs_exclusion_patterns(self) -> list[str]:
if glob_mode:
patterns.append(line)

# validate project root is not excluded by vcs
exclude_spec = pathspec.GitIgnoreSpec.from_lines(patterns)
if exclude_spec.match_file(self.root):
return []

return patterns

def normalize_build_directory(self, build_directory: str) -> str:
Expand Down

0 comments on commit 10d2308

Please sign in to comment.