Skip to content

Commit df6fa49

Browse files
saroad2Byron
authored andcommitted
Find paths ignored in .gitignore
1 parent 8a9f8c5 commit df6fa49

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎git/repo/base.py

+13
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,19 @@ def _get_untracked_files(self, *args, **kwargs):
697697
finalize_process(proc)
698698
return untracked_files
699699

700+
def get_ignored(self, *paths):
701+
"""Checks if paths are ignored via .gitignore
702+
Doing so using the "git check-ignore" method.
703+
704+
:param paths: List of paths to check whether they are ignored or not
705+
:return: sublist of ignored paths
706+
"""
707+
try:
708+
proc = self.git.check_ignore(*paths)
709+
except GitCommandError:
710+
return []
711+
return proc.replace("\\\\", "\\").replace('"', "").split("\n")
712+
700713
@property
701714
def active_branch(self):
702715
"""The name of the currently active branch.

0 commit comments

Comments
 (0)