Skip to content

Commit

Permalink
Move git ignore check to bottom (after all it's the slowest)
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycrosley committed Jun 25, 2021
1 parent 8d57702 commit 23d708e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions isort/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,22 +571,6 @@ def is_skipped(self, file_path: Path) -> bool:

os_path = str(file_path)

if self.skip_gitignore:
if file_path.name == ".git": # pragma: no cover
return True

git_folder = None

for folder in self.git_ignore:
if folder in file_path.parents:
git_folder = folder
break
else:
git_folder = self._check_folder_gitignore(str(file_path.parent))

if git_folder and file_path in self.git_ignore[git_folder]:
return True

normalized_path = os_path.replace("\\", "/")
if normalized_path[1:2] == ":":
normalized_path = normalized_path[2:]
Expand All @@ -610,6 +594,22 @@ def is_skipped(self, file_path: Path) -> bool:
if not (os.path.isfile(os_path) or os.path.isdir(os_path) or os.path.islink(os_path)):
return True

if self.skip_gitignore:
if file_path.name == ".git": # pragma: no cover
return True

git_folder = None

for folder in self.git_ignore:
if folder in file_path.parents:
git_folder = folder
break
else:
git_folder = self._check_folder_gitignore(str(file_path.parent))

if git_folder and file_path in self.git_ignore[git_folder]:
return True

return False

@property
Expand Down

0 comments on commit 23d708e

Please sign in to comment.