Skip to content

git: thin primitives for push-known (remove PushKnownBranches, fix CreateFireBranch)#3

Merged
bschellenberger2600 merged 1 commit into
mainfrom
feat/thin-git-primitives-push-known
Apr 14, 2026
Merged

git: thin primitives for push-known (remove PushKnownBranches, fix CreateFireBranch)#3
bschellenberger2600 merged 1 commit into
mainfrom
feat/thin-git-primitives-push-known

Conversation

@bschellenberger2600
Copy link
Copy Markdown
Member

Summary

This PR tightens git-harness as a thin abstraction over the git CLI: small, composable operations only. Higher-level push-known-branches policy and conflict_strategy handling live in git-fire (see companion PR there).

Breaking change

  • git.PushKnownBranches is removed. It encoded product behavior (which branches to push, how to handle non-fast-forward) inside the library. Consumers should compose the primitives below or follow git-fire’s internal/executor/push_known.go pattern.

New exported APIs (git package)

API Purpose
FetchRemote(repoPath, remote string) error git fetch <remote>
ListLocalBranches(repoPath string) ([]string, error) Local branch short names
ListRemoteBranches(repoPath, remote string) ([]string, error) remote/<branch> short names under that remote
RefIsAncestor(repoPath, ancestorRef, descendantRef string) (bool, error) git merge-base --is-ancestor

Bug fix

  • CreateFireBranch now runs git branch <name> <localSHA> so the backup ref is created at the given commit, not at current HEAD. This is required when the caller is on another branch but must snapshot a diverged / inactive local branch tip (no checkout).

Tests

  • Replaced old PushKnownBranches integration tests with coverage for RefIsAncestor, ListLocalBranches / ListRemoteBranches, and FetchRemote.
  • Existing TestCreateFireBranch continues to validate backup branch creation (now implicitly covers correct startpoint when localSHA matches HEAD in that scenario).

Migration (for downstream modules)

  1. Replace PushKnownBranches(repo, remote) with orchestration that:
    • FetchRemoteListLocalBranches + ListRemoteBranches → classify with GetCommitSHA + RefIsAncestorPushBranch / CreateFireBranch + PushBranch as appropriate.
  2. Or upgrade git-fire to a release that already embeds this logic.

Related

  • git-fire uses replace github.com/git-fire/git-harness => … during development; after this merges, tag v0.2.0 (or next minor) and drop the replace in git-fire in favor of go get github.com/git-fire/git-harness@v0.2.0.

Review focus: API naming, error wrapping on RefIsAncestor edge cases, and whether any other public callers besides git-fire relied on PushKnownBranches (grep before merge).

…anch ref

Remove PushKnownBranches from the harness package so git-fire can own
push-known policy. Export FetchRemote, ListLocalBranches, ListRemoteBranches,
and RefIsAncestor for composition.

CreateFireBranch now runs 'git branch <name> <sha>' so backups point at the
requested commit instead of current HEAD (required for non-checkout branches).

Tests: replace PushKnownBranches coverage with primitives + list-branch smoke.
Made-with: Cursor
@bschellenberger2600 bschellenberger2600 merged commit 377c314 into main Apr 14, 2026
1 check passed
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