fix(auto-commit-service): 🛠 resolve merge conflicts and update diff excerpt

This commit is contained in:
Lilith 2026-01-09 20:10:37 -08:00
parent d9e7f6fef0
commit 1d7590cb74
6 changed files with 47 additions and 18 deletions

View file

@ -40,12 +40,22 @@ class AutoCommitSettings(BaseServiceSettings):
# Repository configuration
repos_base_path: Path = Field(
default=Path("/var/home/lilith/Code/@applications/@lilith/lilith-platform"),
description="Base path containing repositories to process",
default=Path("/var/home/lilith/Code/@packages"),
description="Primary base path containing repositories to process",
)
repos_base_paths: list[Path] = Field(
default=[
Path("/var/home/lilith/Code/@packages"),
Path("/var/home/lilith/Code/@applications/@audio"),
Path("/var/home/lilith/Code/@applications/@image"),
Path("/var/home/lilith/Code/@applications/@lilith"),
Path("/var/home/lilith/Code/@applications/@ml"),
],
description="Additional base paths for recursive discovery",
)
repo_names: list[str] = Field(
default=["codebase", "infrastructure", "tooling", "docs"],
description="Names of subdirectories to process as repositories",
default=[],
description="Names of subdirectories to process as repositories (empty = use recursive discovery)",
)
# Persistent commit history
@ -60,11 +70,11 @@ class AutoCommitSettings(BaseServiceSettings):
# Recursive discovery settings
recursive_discovery: bool = Field(
default=False,
default=True,
description="Auto-discover git repos recursively",
)
recursive_depth: int | None = Field(
default=None,
default=4,
description="Max depth for recursive discovery (None = unlimited)",
)
cache_update_minutes: int = Field(
@ -72,7 +82,7 @@ class AutoCommitSettings(BaseServiceSettings):
description="Minutes between repo cache refreshes",
)
exclude_patterns: list[str] = Field(
default=["node_modules", "pyvenv", ".venv", "venv", "dist", "build"],
default=["node_modules", "pyvenv", ".venv", "venv", "dist", "build", "__pycache__"],
description="Patterns to exclude from recursive discovery",
)

View file

@ -46,13 +46,13 @@ def discover_git_repos(
# Path is not relative to base_path, skip
continue
# Check for .git directory BEFORE filtering
has_git = ".git" in dirs
# Filter excluded directories IN-PLACE
# This prevents os.walk from descending into them
dirs[:] = [d for d in dirs if d not in exclude_set]
# Check for .git directory BEFORE clearing for depth limit
has_git = ".git" in dirs
# Check depth limit - stop descending but still check current level
if max_depth is not None and current_depth >= max_depth:
dirs.clear() # Don't descend further

View file

@ -5,6 +5,7 @@ import logging
import uuid
from collections import deque
from datetime import datetime, timedelta
from pathlib import Path
from typing import Any
from ..commit_history import CommitHistory
@ -120,15 +121,33 @@ class CommitDaemon:
def _discover_and_cache_repos(self) -> list[Repository]:
"""Discover repos recursively and cache results."""
repo_paths = discover_git_repos(
base_path=self.settings.repos_base_path,
max_depth=self.settings.recursive_depth,
exclude_patterns=self.settings.exclude_patterns,
)
# Use repos_base_paths if available, otherwise fall back to repos_base_path
base_paths = getattr(self.settings, 'repos_base_paths', None)
if not base_paths:
base_paths = [self.settings.repos_base_path]
all_repo_paths: list[Path] = []
path_to_base: dict[Path, Path] = {}
for base_path in base_paths:
if not base_path.exists():
logger.warning(f"Base path does not exist: {base_path}")
continue
repo_paths = discover_git_repos(
base_path=base_path,
max_depth=self.settings.recursive_depth,
exclude_patterns=self.settings.exclude_patterns,
)
for path in repo_paths:
if path not in path_to_base:
all_repo_paths.append(path)
path_to_base[path] = base_path
repos = []
for path in repo_paths:
name = str(path.relative_to(self.settings.repos_base_path))
for path in all_repo_paths:
base = path_to_base[path]
name = str(path.relative_to(base))
repos.append(
Repository(
name=name,
@ -139,7 +158,7 @@ class CommitDaemon:
)
self._cache_updated_at = datetime.now()
logger.info(f"Discovered {len(repos)} repositories")
logger.info(f"Discovered {len(repos)} repositories across {len(base_paths)} base paths")
return repos
def _should_refresh_cache(self) -> bool: