summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorSagi Shadur <saroad2@gmail.com>2020-09-28 23:05:29 +0300
committerSebastian Thiel <sebastian.thiel@icloud.com>2020-09-29 14:24:10 +0800
commitdf6fa49c0662104a5f563a3495c8170e2865e31b (patch)
treebde590c81804a0fb11d39268de9f71938f53188b /git
parent8a9f8c55d6a58fe42fe67e112cbc98de97140f75 (diff)
downloadgitpython-df6fa49c0662104a5f563a3495c8170e2865e31b.tar.gz
Find paths ignored in .gitignore
Diffstat (limited to 'git')
-rw-r--r--git/repo/base.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/git/repo/base.py b/git/repo/base.py
index 69e3e313..ed976b2c 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -697,6 +697,19 @@ class Repo(object):
finalize_process(proc)
return untracked_files
+ def get_ignored(self, *paths):
+ """Checks if paths are ignored via .gitignore
+ Doing so using the "git check-ignore" method.
+
+ :param paths: List of paths to check whether they are ignored or not
+ :return: sublist of ignored paths
+ """
+ try:
+ proc = self.git.check_ignore(*paths)
+ except GitCommandError:
+ return []
+ return proc.replace("\\\\", "\\").replace('"', "").split("\n")
+
@property
def active_branch(self):
"""The name of the currently active branch.