diff --git a/src/serena/util/file_system.py b/src/serena/util/file_system.py index 26a59438..e4195aec 100644 --- a/src/serena/util/file_system.py +++ b/src/serena/util/file_system.py @@ -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