feat: implement .gitignore support in file watcher

This commit is contained in:
2026-03-06 20:40:48 +01:00
parent 5f7649867b
commit 10385bb1c2
2 changed files with 18 additions and 1 deletions

View File

@@ -34,6 +34,18 @@ class GitManager:
except (exc.InvalidGitRepositoryError, exc.NoSuchPathError):
return False
def is_ignored(self, file_path):
"""Check if a file is ignored by .gitignore rules."""
if not self.repo:
return False
try:
# git check-ignore returns the path if it is ignored
ignored_files = self.repo.ignored(file_path)
return len(ignored_files) > 0
except Exception as e:
logger.error(f"Error checking ignore status for {file_path}: {e}")
return False
def commit_change(self, action, file_name):
if not self.repo:
logger.error("No repository loaded for commit.")