git: thin primitives for push-known (remove PushKnownBranches, fix CreateFireBranch)#3
Merged
Conversation
…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
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 tightens git-harness as a thin abstraction over the
gitCLI: small, composable operations only. Higher-level push-known-branches policy andconflict_strategyhandling live in git-fire (see companion PR there).Breaking change
git.PushKnownBranchesis 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’sinternal/executor/push_known.gopattern.New exported APIs (
gitpackage)FetchRemote(repoPath, remote string) errorgit fetch <remote>ListLocalBranches(repoPath string) ([]string, error)ListRemoteBranches(repoPath, remote string) ([]string, error)remote/<branch>short names under that remoteRefIsAncestor(repoPath, ancestorRef, descendantRef string) (bool, error)git merge-base --is-ancestorBug fix
CreateFireBranchnow runsgit 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
PushKnownBranchesintegration tests with coverage forRefIsAncestor,ListLocalBranches/ListRemoteBranches, andFetchRemote.TestCreateFireBranchcontinues to validate backup branch creation (now implicitly covers correct startpoint whenlocalSHAmatches HEAD in that scenario).Migration (for downstream modules)
PushKnownBranches(repo, remote)with orchestration that:FetchRemote→ListLocalBranches+ListRemoteBranches→ classify withGetCommitSHA+RefIsAncestor→PushBranch/CreateFireBranch+PushBranchas appropriate.Related
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 ofgo get github.com/git-fire/git-harness@v0.2.0.Review focus: API naming, error wrapping on
RefIsAncestoredge cases, and whether any other public callers besides git-fire relied onPushKnownBranches(grep before merge).