Skip to content

Commit 11c06ab

Browse files
Merge pull request #1773 from ucodery/main
Symlinked paths are excluded from gitignore checks
2 parents 191e165 + 2bbf393 commit 11c06ab

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

isort/settings.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,15 @@ def _check_folder_gitignore(self, folder: str) -> Optional[Path]:
548548

549549
git_folder = Path(topfolder_result.rstrip()).resolve()
550550

551-
files = [str(p) for p in Path(git_folder).rglob("*")]
551+
files: List[str] = []
552+
# don't check symlinks; either part of the repo and would be checked
553+
# twice, or is external to the repo and git won't konw anything about it
554+
for root, _dirs, git_files in os.walk(git_folder, followlinks=False):
555+
for git_file in git_files:
556+
git_path = os.path.join(root, git_file)
557+
# followlinks only disables walking into linked dirs
558+
if not os.path.islink(git_path):
559+
files.append(git_path)
552560
git_options = ["-C", str(git_folder), "-c", "core.quotePath="]
553561
try:
554562
ignored = subprocess.check_output( # nosec # skipcq: PYL-W1510

0 commit comments

Comments
 (0)