Skip to content

Centralize repository context resolution for repo and pull request workflows #35

@hex2dec

Description

@hex2dec

Follow-up to #2.

Summary

Move Git-derived repository context logic into a deeper shared module so repo and PR workflows rely on one consistent source of truth.

Problem

Repository inference and branch validation logic is currently split between the repository-context module and PR-specific code. That duplication makes behavior harder to reason about and increases the chance of drift.

Scope

  • Extend the repository-context layer to cover current branch resolution.
  • Extend the repository-context layer to cover origin remote parsing.
  • Extend the repository-context layer to cover upstream tracking validation.
  • Extend the repository-context layer to cover origin-only branch checks used by PR creation.
  • Refactor repo and PR workflows to use the centralized context APIs.

Non-goals

  • Do not add support for complex cross-fork or multi-remote PR creation workflows.
  • Do not change the public command surface.
  • Do not change JSON output contracts.

Acceptance Criteria

  • repo view local-context behavior uses the centralized repository-context module.
  • pr create local head resolution and origin/upstream validation use the centralized repository-context module.
  • Shared Git error paths remain stable and test-backed.
  • Repository-context tests cover HTTPS origin URLs.
  • Repository-context tests cover SSH origin URLs.
  • Repository-context tests cover missing origin remotes.
  • Repository-context tests cover detached HEAD state.
  • Repository-context tests cover branches not pushed to origin.
  • Repository-context tests cover branches tracking a non-origin remote.
  • The PR-specific duplicated Git inspection logic is removed or reduced to thin orchestration.

Notes

This issue is about architectural consolidation, not expanding workflow scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions