refactor(core): standardize commit timestamp extraction and backup ref parsing - #81
Merged
Merged
Conversation
…f parsing - Add GitRepo.get_commit_timestamp helper in git_wrapper.py - Add BackupRefInfo dataclass, parse_backup_ref, get_remote_backup_ref, and fetch_backup_refs in ops.py - Replace ad-hoc log parsing and ref splitting across daemon.py, ops.py, system.py, and cli.py - Add unit tests for timestamp extraction, ref parsing, and remote ref fetching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR resolves DRY violations related to Git commit timestamp extraction, remote tracking reference construction, and backup ref parsing:
Standardized Commit Timestamp Extraction:
GitRepo.get_commit_timestamp(self, ref: str) -> int | Noneingit_wrapper.py.git log -1 --format=%ctinvocations and ad-hoc parsing acrossdaemon.py,ops.py, andcli.py.Structured Backup Reference Parsing:
BackupRefInfodataclass andparse_backup_ref(ref: str) -> BackupRefInfo | Noneinops.py.split('/')[-2]and dynamic slice indexing acrossops.get_remote_drift_state,ops.sync_session,ops.finalize_work, andsystem._fetch_remote_identities.Consolidated Remote Backup Ref Formatting & Fetching:
ops.get_remote_backup_ref(branch: str, remote_name: str = 'origin') -> str.ops.fetch_backup_refs(repo: GitRepo, branch: str | None = None, remote_name: str = 'origin') -> bool.daemon.run_backup,cli.show_status,ops.get_remote_drift_state,ops.sync_session, andops.finalize_work.Automated Tests:
GitRepo.get_commit_timestamp.parse_backup_ref,get_remote_backup_ref, andfetch_backup_refs.Verification
ruff check,ruff format,mypy) passing cleanly.