diff --git a/aocsync.py b/aocsync.py index ef4f948..edfe749 100755 --- a/aocsync.py +++ b/aocsync.py @@ -443,6 +443,38 @@ class CargoAOCRunner: logger.warning(f"Could not get git rev for {repo_path}: {e}") return "" + @staticmethod + def get_recent_commits(repo_path: Path, count: int = 2) -> List[dict]: + """Get recent git commit messages and timestamps""" + commits = [] + try: + result = subprocess.run( + ['git', 'log', f'-{count}', '--pretty=format:%H|%s|%ai', '--date=iso'], + cwd=repo_path, + capture_output=True, + text=True, + timeout=5 + ) + if result.returncode == 0: + for line in result.stdout.strip().split('\n'): + if line: + parts = line.split('|', 2) + if len(parts) >= 3: + commits.append({ + 'hash': parts[0][:7], # Short hash + 'message': parts[1], + 'timestamp': parts[2] + }) + elif len(parts) == 2: + commits.append({ + 'hash': parts[0][:7], + 'message': parts[1], + 'timestamp': '' + }) + except Exception as e: + logger.warning(f"Could not get recent commits for {repo_path}: {e}") + return commits + @staticmethod def run_benchmarks(repo_path: Path, year: int, user: str = "unknown", repo_url: str = "", is_multi_year: bool = False) -> List[PerformanceResult]: @@ -824,7 +856,7 @@ class HTMLGenerator: 'repo_url': repo_url } - html = self._generate_html(data, years, users, db) + html = self._generate_html(data, years, users, db, config) output_file = self.output_dir / 'index.html' with open(output_file, 'w') as f: @@ -923,7 +955,78 @@ class HTMLGenerator: svg_parts.append('') return ''.join(svg_parts) - def _generate_html(self, data: dict, years: List[int], users: List[str], db: Database) -> str: + def _generate_compact_commits_for_year(self, config: Config, year: int) -> str: + """Generate compact commit log for a specific year""" + commits_data = [] + + # Collect commits for all repositories for this year + for repo_config in config.repositories: + repo_type = repo_config.get('type', 'single') + user_name = repo_config['name'] + + if repo_type == 'single': + # Check if this repo has data for this year + local_path = repo_config.get('local_path', '') + repo_url = repo_config.get('url', '') + if local_path: + repo_path = Path(local_path) + # Check if year directory exists + year_dir = repo_path / str(year) + if year_dir.exists() and year_dir.is_dir(): + commits = CargoAOCRunner.get_recent_commits(repo_path, count=2) + if commits: + commits_data.append({ + 'user': user_name, + 'repo_url': repo_url, + 'commits': commits + }) + + elif repo_type == 'multi-year': + years_config = repo_config.get('years', []) + for year_config in years_config: + if year_config['year'] == year: + local_path = year_config.get('local_path', '') + repo_url = year_config.get('url', '') + if local_path: + repo_path = Path(local_path) + if repo_path.exists(): + commits = CargoAOCRunner.get_recent_commits(repo_path, count=2) + if commits: + commits_data.append({ + 'user': user_name, + 'repo_url': repo_url, + 'commits': commits + }) + + # Generate HTML if we have any commits + if not commits_data: + return '' + + html = '