Skip to content

run fetch before push operations#75

Open
skarim wants to merge 3 commits intoskarim/unstack-cleanupfrom
skarim/fetch-before-push
Open

run fetch before push operations#75
skarim wants to merge 3 commits intoskarim/unstack-cleanupfrom
skarim/fetch-before-push

Conversation

@skarim
Copy link
Copy Markdown
Collaborator

@skarim skarim commented May 5, 2026

Adds a targeted git fetch of active stack branches before every git push call. This fixes --force-with-lease rejections for users with shallow clones, where remote tracking refs may be stale or missing.

Changes

  • New FetchBranches(remote, branches) in the git layer — fetches only the specific branches being pushed
  • push — fetch active branches before push (also switches to non-atomic push)
  • submit — fetch active branches before the per-branch push loop
  • link — fetch specified branches before push

Stack created with GitHub Stacks CLIGive Feedback 💬

Copilot AI review requested due to automatic review settings May 5, 2026 04:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a branch-scoped fetch helper to the git layer and wires it into stack push flows so branch refs are refreshed immediately before pushing. It touches the CLI commands that publish stack branches (push, submit, and link) plus their test coverage.

Changes:

  • Add FetchBranches(remote, branches) to the git ops interface, default implementation, wrapper, and test mock.
  • Run the new fetch step before push operations in submit, push, and link.
  • Add tests for fetch-before-push ordering, and update push expectations around atomic push behavior.
Show a summary per file
File Description
internal/git/mock_ops.go Extends the git mock with a branch-scoped fetch hook for tests.
internal/git/gitops.go Adds the concrete FetchBranches implementation to the git ops layer.
internal/git/git.go Exposes the new fetch helper through the package-level API.
cmd/submit.go Fetches active remote branches before sequential submit pushes.
cmd/submit_test.go Verifies submit performs fetch before pushing stack branches.
cmd/push.go Fetches active branches before push and changes push atomicity.
cmd/push_test.go Adds fetch-before-push coverage and updates push behavior assertions.
cmd/link.go Fetches candidate branches before pushing them during link.
cmd/link_test.go Verifies link performs fetch before push.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 9/9 changed files
  • Comments generated: 3

Comment thread internal/git/gitops.go
Comment on lines +114 to +116
args := []string{"fetch", remote}
args = append(args, branches...)
return runSilent(args...)
Comment thread cmd/push.go
Comment thread cmd/link.go Outdated
Copy link
Copy Markdown
Collaborator Author

@skarim skarim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed review feedback.

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.

2 participants