From 66bef1d7ed17f00e7b554ca5413e336970489253 Mon Sep 17 00:00:00 2001 From: Kwuang Tang <10319942+cktang88@users.noreply.github.com> Date: Fri, 14 Apr 2023 18:02:21 -0400 Subject: [PATCH] Ignore files from .gitignore in Git loader (#2909) fixes #2905 extends #2851 --- langchain/document_loaders/git.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/langchain/document_loaders/git.py b/langchain/document_loaders/git.py index eb10dcde..a862e8f0 100644 --- a/langchain/document_loaders/git.py +++ b/langchain/document_loaders/git.py @@ -54,6 +54,10 @@ class GitLoader(BaseLoader): file_path = os.path.join(self.repo_path, item.path) + ignored_files = repo.ignored([file_path]) + if len(ignored_files): + continue + # uses filter to skip files if self.file_filter and not self.file_filter(file_path): continue