Fix bugs and logging

This commit is contained in:
Alex Selimov 2025-06-09 22:00:16 -04:00
parent c4c696df5a
commit a373d9ca4e
3 changed files with 14 additions and 20 deletions

View file

@ -5,7 +5,7 @@ from typing import List, Optional
from reviewllama.git_diff import analyze_git_repository from reviewllama.git_diff import analyze_git_repository
from .configs import OllamaConfig, ReviewConfig, create_config_from_vars from .configs import ReviewConfig, create_config_from_vars
from .logger import (log_git_analysis_result, log_git_analysis_start, from .logger import (log_git_analysis_result, log_git_analysis_start,
log_paths, log_review_start) log_paths, log_review_start)
@ -108,8 +108,8 @@ def cli() -> None:
# TODO: Pass config to review engine # TODO: Pass config to review engine
log_review_start(config) log_review_start(config)
log_paths(config.paths) log_paths(config.paths)
for path in Paths: for path in config.paths:
analysis = analyze_git_repository(path, config.base_branch) analysis = analyze_git_repository(path, config.base_branch)
log_git_analysis_start(path, config.base_branch) log_git_analysis_start(path, config.base_branch)
log_git_analysis_result(analysis) log_git_analysis_result(analysis)

View file

@ -2,8 +2,6 @@ from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from typing import List from typing import List
from .cli import normalize_server_url
@dataclass(frozen=True) @dataclass(frozen=True)
class OllamaConfig: class OllamaConfig:
@ -30,7 +28,7 @@ def create_ollama_config(
"""Create OllamaConfig with validated parameters.""" """Create OllamaConfig with validated parameters."""
return OllamaConfig( return OllamaConfig(
model=model, model=model,
server_url=normalize_server_url(server_url), server_url=server_url,
timeout=timeout, timeout=timeout,
max_retries=max_retries, max_retries=max_retries,
) )

View file

@ -22,18 +22,18 @@ def log_review_start(config: ReviewConfig) -> None:
console = create_console() console = create_console()
"""Log the start of review process with colored output.""" """Log the start of review process with colored output."""
console.print( console.print(
f"[bold blue]ReviewLlama[/bold blue] - Starting review of {len(config.paths)} path(s)", f"ReviewLlama - Starting review of {len(config.paths)} path(s)",
style="bold", style="bold",
) )
console.print(f"[dim]Model:[/dim] [cyan]{config.ollama.model}[/cyan]") console.print(f"Model: [cyan]{config.ollama.model}[/cyan]")
console.print(f"[dim]Server:[/dim] [cyan]{config.ollama.server_url}[/cyan]") console.print(f"Server: [cyan]{config.ollama.server_url}[/cyan]")
console.print() console.print()
def log_paths(paths: List[Path]) -> None: def log_paths(paths: List[Path]) -> None:
"""Log the paths being reviewed with colored output.""" """Log the paths being reviewed with colored output."""
console = create_console() console = create_console()
console.print("[bold]Paths to review:[/bold]") console.print("Paths to review:")
for path in paths: for path in paths:
console.print(f"{path}") console.print(f"{path}")
console.print() console.print()
@ -47,21 +47,17 @@ def log_error(error: str) -> None:
def log_git_analysis_start(path: Path, base_branch: str) -> None: def log_git_analysis_start(path: Path, base_branch: str) -> None:
"""Log the start of git analysis.""" """Log the start of git analysis."""
console = create_console console = create_console()
console.print(f"[dim]Analyzing git repository at:[/dim] [yellow]{path}[/yellow]") console.print(f"[dim]Analyzing git repository at:[/dim] {path}")
console.print(f"[dim]Base branch:[/dim] [cyan]{base_branch}[/cyan]") console.print(f"[dim]Base branch:[/dim] {base_branch}")
def log_git_analysis_result(analysis: GitAnalysis) -> None: def log_git_analysis_result(analysis: GitAnalysis) -> None:
"""Log the results of git analysis.""" """Log the results of git analysis."""
console = create_console() console = create_console()
console.print( console.print(f"[dim]Current branch:[/dim] {analysis.current_branch}")
f"[dim]Current branch:[/dim] [green]{analysis.current_branch}[/green]" console.print(f"[dim]Comparing against:[/dim] {analysis.base_branch}")
) console.print(f"[dim]Files changed:[/dim] {analysis.total_files_changed}")
console.print(f"[dim]Comparing against:[/dim] [cyan]{analysis.base_branch}[/cyan]")
console.print(
f"[dim]Files changed:[/dim] [yellow]{analysis.total_files_changed}[/yellow]"
)
if analysis.diffs: if analysis.diffs:
console.print("\n[bold]Changed files:[/bold]") console.print("\n[bold]Changed files:[/bold]")