Skip to content

Find paths ignored in .gitignore #1063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down