Skip to content

refactor: dedupe commit-tree-with-identity helper across storage/issues.py and storage/prs.py #33

@davidpoblador

Description

@davidpoblador

Summary

Two private helpers do exactly the same job under different names:

  • `storage/issues.py:_commit_with_identity`
  • `storage/prs.py:_commit`

Both:

  1. Build a `-c user.name=... -c user.email=... commit-tree ` argv list.
  2. Add `-p ` for each parent.
  3. Optionally set `GIT_AUTHOR_DATE` / `GIT_COMMITTER_DATE` env vars from `authored_at`.
  4. Run the subprocess and return `stdout.strip()`.

The two implementations diverge only in cosmetic comments. The `prs.py` copy already has a comment saying "mirrors issues._commit_with_identity" — flagging the duplication.

Suggested approach

Hoist into `gitcabin.storage.repo.BareRepo` as a method (e.g. `commit_tree(...)`) or into a new module-level helper in `storage/_git_objects.py`. Both `storage/issues.py` and `storage/prs.py` import it.

While we're there: consider hoisting the small set of underscored tree-helpers (`_entries_of`, `_load_commit`, `_read_blob`, `_subtree_or_none`, `_TreeEntry`, `_write_tree`) that `storage/prs.py` already imports from `storage/issues.py` — same shape of cross-module-private-import would benefit from a shared home (see #N for the layering issue).

Severity

Pure refactor; no behavior change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions