From c138d35aa1877f68f8df1c0a5d7aa324102c9000 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 5 Feb 2026 17:14:02 +0000 Subject: [PATCH] Initial upload: Add repohealth-cli project with CI/CD workflow --- src/repohealth/models/author.py | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/repohealth/models/author.py diff --git a/src/repohealth/models/author.py b/src/repohealth/models/author.py new file mode 100644 index 0000000..ac86c2c --- /dev/null +++ b/src/repohealth/models/author.py @@ -0,0 +1,42 @@ +"""Author statistics data models.""" + +from dataclasses import dataclass, field +from typing import Optional +from datetime import datetime + + +@dataclass +class AuthorStats: + """Statistics for a single author across the repository.""" + + name: str + email: str + total_commits: int = 0 + files_touched: set[str] = field(default_factory=set) + first_commit: Optional[datetime] = None + last_commit: Optional[datetime] = None + modules_contributed: set[str] = field(default_factory=set) + unique_contributions: int = 0 + total_contributions: int = 0 + + @property + def ownership_percentage(self) -> float: + """Get percentage of total repository contributions.""" + return 0.0 + + def add_file(self, file_path: str, module: str) -> None: + """Record a contribution to a file.""" + self.files_touched.add(file_path) + self.modules_contributed.add(module) + self.total_contributions += 1 + + def merge(self, other: "AuthorStats") -> None: + """Merge another AuthorStats into this one.""" + self.total_commits += other.total_commits + self.files_touched.update(other.files_touched) + self.modules_contributed.update(other.modules_contributed) + self.unique_contributions = len(self.files_touched) + if other.first_commit and (not self.first_commit or other.first_commit < self.first_commit): + self.first_commit = other.first_commit + if other.last_commit and (not self.last_commit or other.last_commit > self.last_commit): + self.last_commit = other.last_commit