diff --git a/git/repo/base.py b/git/repo/base.py index 69e3e3136..a935cfa79 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -697,6 +697,19 @@ def _get_untracked_files(self, *args, **kwargs): finalize_process(proc) return untracked_files + def 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: subset of those paths which are ignored + """ + 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.