Skip to content

Add git replay update strategy#402

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-update-strategy-replay
Draft

Add git replay update strategy#402
Copilot wants to merge 3 commits intomainfrom
copilot/add-update-strategy-replay

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

Summary

Adds support for the experimental git replay command as a new replay update strategy when updating a stack.

Changes

New --replay flag

  • Added --replay option to CommonOptions, wired into UpdateStackCommand and SyncStackCommand
  • Strategy selection prompt now includes Replay alongside Merge and Rebase
  • Specifying multiple strategies (--rebase, --merge, --replay) now raises a clear error

git replay support in GitClient

  • IGitClient/GitClient gain ReplayFromSourceBranch(branchName, sourceBranchName, upstreamSha) and ReplayOntoNewParent(branchName, newParentBranchName, oldParentCommitSha) methods
  • Each method runs git replay --onto <newbase> <upstream>..<branch> and then calls git update-ref with the output — no working directory changes required
  • Conflict detection: checks stdout/stderr for CONFLICT markers; any non-zero exit throws ProcessException (or ConflictException on conflict)

Replay strategy in StackActions

  • UpdateStackUsingReplay follows the same branch-line traversal and squash-merge re-parenting logic as the rebase strategy
  • Since git replay doesn't touch the working directory, no branch switching is needed
  • The upstream SHA for each replay is taken from the pre-operation branchStatuses snapshot, ensuring correct ranges even after parent branches have been updated
  • Conflict handling: ConflictException is caught and re-thrown with a user-friendly message explaining that interactive resolution is not possible; users should resolve manually and retry with a different strategy

Tests

  • UpdateStack_UsingReplay_WhenNoConflicts_CallsReplayForEachBranch — verifies ReplayFromSourceBranch is called for each branch with correct upstream SHAs and that no ChangeBranch calls are made
  • UpdateStack_UsingReplay_WhenConflictDetected_ThrowsConflictException — verifies conflicts surface as exceptions
  • UpdateStack_UsingReplay_WhenBranchHasMergedPullRequest_SkipsBranch — verifies inactive branches are skipped
  • UpdateStack_UsingReplay_WhenBranchHasNoRemoteTrackingBranch_IsUpdated — verifies local-only branches are still replayed
  • WhenReplayIsSpecified_StackIsUpdatedUsingReplay — command handler test
  • WhenReplayAndRebaseAreSpecified_Throws — command handler test for mutual exclusion

Copilot AI and others added 2 commits May 7, 2026 11:38
Agent-Logs-Url: https://github.com/geofflamrock/stack/sessions/e1f9279d-3940-4541-90c3-8d55a41ec675

Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
…layOntoNewParent

Agent-Logs-Url: https://github.com/geofflamrock/stack/sessions/e1f9279d-3940-4541-90c3-8d55a41ec675

Co-authored-by: geofflamrock <2915931+geofflamrock@users.noreply.github.com>
@geofflamrock geofflamrock force-pushed the copilot/add-update-strategy-replay branch from 087a137 to 3036989 Compare May 7, 2026 01:38
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