Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/checkup-git/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "checkup-git"
version = "0.4.0"
version = "0.4.1"
description = "Git metrics for checkup"
readme = "README.md"
requires-python = ">=3.12"
Expand Down
35 changes: 14 additions & 21 deletions plugins/checkup-git/src/checkup_git/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,23 @@ def provide(self) -> dict[str, Any]:
}

def _get_last_commit_date(self, git_files: list[str]) -> datetime | None:
"""Get the date of the most recent commit to any tracked file."""
"""
Get the date of the most recent commit to any tracked file.
"""

if not git_files:
return None

last_commit_dates = [
date
for file in git_files
if (date := self._get_file_last_commit_date(file)) is not None
]

return max(last_commit_dates) if last_commit_dates else None
result = subprocess.run(
["git", "log", "-1", "--format=%aI", "--", "."],
cwd=self.repo_path,
capture_output=True,
text=True,
)
date_str = result.stdout.strip()
if not date_str:
return None
return datetime.fromisoformat(date_str)

def _get_tracked_files(self) -> list[str]:
"""List all git tracked files in the repo path."""
Expand All @@ -80,16 +86,3 @@ def _get_tracked_files(self) -> list[str]:
logger.warning(f"Failed to list git files: {result.stderr}")
return []
return result.stdout.splitlines()

def _get_file_last_commit_date(self, file: str) -> datetime | None:
"""Get the last commit date for a specific file."""
result = subprocess.run(
["git", "log", "-1", "--format=%aI", "--", file],
cwd=self.repo_path,
capture_output=True,
text=True,
)
date_str = result.stdout.strip()
if not date_str:
return None
return datetime.fromisoformat(date_str)
6 changes: 5 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading