Skip to content

Commit

Permalink
Prevent matching bogus parent gitignores
Browse files Browse the repository at this point in the history
If our project is 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 Jul 26, 2024
1 parent 3adae6c commit 3e12180
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 3e12180

Please sign in to comment.