Skip to content

Commit

Permalink
fix: check if gitignore exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Aug 20, 2024
1 parent c785cfe commit d664f4b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gptme/tools/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ def _gitignore():
"""Read the gitignore, return a list of ignored patterns."""

project_root = Path(".")
with open(project_root / ".gitignore") as f:
gitignore = f.read()
git_ignore = project_root / ".gitignore"
if not git_ignore.exists():
return []

with git_ignore.open("r") as f:
gitignore = f.read()
ignored = []
for line in gitignore.splitlines():
if not line.startswith("#"):
Expand Down

0 comments on commit d664f4b

Please sign in to comment.