Skip to content

Commit f58a8cc

Browse files
Normalize Windows paths and handle directory paths for include patterns (#217)
1 parent db91b57 commit f58a8cc

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/gitingest/ingestion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from gitingest.utils.path_utils import _is_safe_symlink
1313

1414
try:
15-
import tomllib
15+
import tomllib # type: ignore[import]
1616
except ImportError:
1717
import tomli as tomllib
1818

src/gitingest/query_parsing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ def _parse_patterns(pattern: Union[str, Set[str]]) -> Set[str]:
296296
# Remove empty string if present
297297
parsed_patterns = parsed_patterns - {""}
298298

299+
# Normalize Windows paths to Unix-style paths
300+
parsed_patterns = {p.replace("\\", "/") for p in parsed_patterns}
301+
299302
# Validate and normalize each pattern
300303
for p in parsed_patterns:
301304
if not _is_valid_pattern(p):

src/gitingest/utils/ingestion_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def _should_include(path: Path, base_path: Path, include_patterns: Set[str]) ->
5656
return False
5757

5858
rel_str = str(rel_path)
59+
if path.is_dir():
60+
rel_str += "/"
61+
5962
for pattern in include_patterns:
6063
if fnmatch(rel_str, pattern):
6164
return True

0 commit comments

Comments
 (0)