Skip to content

refactor(core): standardize commit timestamp extraction and backup ref parsing - #81

Merged
JacksonFergusonDev merged 1 commit into
mainfrom
refactor/git-timestamp-and-ref-parsing
Aug 22, 2026
Merged

refactor(core): standardize commit timestamp extraction and backup ref parsing#81
JacksonFergusonDev merged 1 commit into
mainfrom
refactor/git-timestamp-and-ref-parsing

Conversation

@JacksonFergusonDev

Copy link
Copy Markdown
Owner

Summary

This PR resolves DRY violations related to Git commit timestamp extraction, remote tracking reference construction, and backup ref parsing:

  1. Standardized Commit Timestamp Extraction:

    • Added GitRepo.get_commit_timestamp(self, ref: str) -> int | None in git_wrapper.py.
    • Replaced scattered git log -1 --format=%ct invocations and ad-hoc parsing across daemon.py, ops.py, and cli.py.
  2. Structured Backup Reference Parsing:

    • Introduced BackupRefInfo dataclass and parse_backup_ref(ref: str) -> BackupRefInfo | None in ops.py.
    • Replaced fragile split('/')[-2] and dynamic slice indexing across ops.get_remote_drift_state, ops.sync_session, ops.finalize_work, and system._fetch_remote_identities.
  3. Consolidated Remote Backup Ref Formatting & Fetching:

    • Added ops.get_remote_backup_ref(branch: str, remote_name: str = 'origin') -> str.
    • Added ops.fetch_backup_refs(repo: GitRepo, branch: str | None = None, remote_name: str = 'origin') -> bool.
    • Replaced duplicate fetch refspecs and string stripping in daemon.run_backup, cli.show_status, ops.get_remote_drift_state, ops.sync_session, and ops.finalize_work.
  4. Automated Tests:

    • Added unit tests for GitRepo.get_commit_timestamp.
    • Added unit tests for parse_backup_ref, get_remote_backup_ref, and fetch_backup_refs.

Verification

  • All 162 pytest tests passing locally.
  • Pre-commit hooks (ruff check, ruff format, mypy) passing cleanly.

…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
@JacksonFergusonDev
JacksonFergusonDev merged commit 9876b6e into main Aug 22, 2026
7 checks passed
@JacksonFergusonDev
JacksonFergusonDev deleted the refactor/git-timestamp-and-ref-parsing branch August 22, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant