diff --git a/backend/src/hatchling/builders/config.py b/backend/src/hatchling/builders/config.py index da4a9f9b9..d5b6b27dc 100644 --- a/backend/src/hatchling/builders/config.py +++ b/backend/src/hatchling/builders/config.py @@ -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: