mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 08:15:59 +00:00
GitignoreParser.should_ignore: Always ignore paths outside of the repository root #330
This commit is contained in:
1 parent
aa52c6cfe0
commit
f2b01a0573
1 file changed
+10
-1
@@ -1,4 +1,5 @@
|
||||
import glob
|
||||
import logging
|
||||
import os
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass, field
|
||||
@@ -7,6 +8,8 @@ from typing import NamedTuple
|
||||
import pathspec
|
||||
from pathspec import PathSpec
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ScanResult(NamedTuple):
|
||||
"""Result of scanning a directory."""
|
||||
@@ -243,7 +246,13 @@ class GitignoreParser:
|
||||
"""
|
||||
# Convert to relative path from repo root
|
||||
if os.path.isabs(path):
|
||||
rel_path = os.path.relpath(path, self.repo_root)
|
||||
try:
|
||||
rel_path = os.path.relpath(path, self.repo_root)
|
||||
except Exception as e:
|
||||
# If the path could not be converted to a relative path,
|
||||
# it is outside the repository root, so we ignore it
|
||||
log.info("Ignoring path '%s' which is outside of the repository root (%s)", path, e)
|
||||
return True
|
||||
else:
|
||||
rel_path = path
|
||||
|
||||
|
||||
Reference in new issue
Block a user