Skip to content

fixes #43 Merge resolved conflicts into terminal branch before cleanup#44

Merged
mattsgarlata merged 1 commit intomainfrom
issue-43-terminal-branch-fast-forward
Mar 25, 2026
Merged

fixes #43 Merge resolved conflicts into terminal branch before cleanup#44
mattsgarlata merged 1 commit intomainfrom
issue-43-terminal-branch-fast-forward

Conversation

@mattsgarlata
Copy link
Copy Markdown
Member

Closes #43

advanceBranchHereFromMergeForward skipped the terminal branch entirely, so when a conflict resolution PR merged into merge-forward-pr-{N}-main, the cleanup deleted that branch without ever updating main. The resolved changes were lost.

Now it merges the merge-forward content into main (via --no-ff merge commit) before deleting the branch.

Made with Cursor

advanceBranchHereFromMergeForward skipped the terminal branch entirely,
so when a conflict resolution PR merged into merge-forward-pr-{N}-main,
the cleanup deleted that branch without ever updating main. Now it
merges the merge-forward content into main before deleting the branch.

Made-with: Cursor
@mattsgarlata mattsgarlata marked this pull request as ready for review March 25, 2026 11:56
@mattsgarlata mattsgarlata requested a review from jerryorr March 25, 2026 11:57
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

Walkthrough

The changes implement fast-forwarding of the terminal branch when merge-forward PRs are successfully merged, addressing cases where conflict resolutions on the last hop into main were not being propagated. A new fastForwardTerminalBranch method checks out the terminal branch, pulls remote updates, creates a merge commit from the merge-forward branch, and pushes the result. Tests are updated to validate this behavior.

Changes

Cohort / File(s) Summary
Terminal Branch Fast-Forward Implementation
src/branch-maintainer.js
Added fastForwardTerminalBranch() async method that fast-forwards the terminal branch via checkout, merge, and push operations. Modified advanceBranchHereFromMergeForward() to delegate to this new method instead of skipping the terminal branch.
Unit Test Updates
test/branch-maintainer-test.js
Updated advanceBranchHereFromMergeForward test case to assert that terminal-branch fast-forwarding executes git checkout, git merge from merge-forward branch, and git push operations.
Integration Test Addition
test/real-git-test.js
Added new integration test for issue #43 validating that resolved conflicts on the terminal branch are fast-forwarded to main. Adjusted upstream tracking in existing git push command (-u flag).

Sequence Diagram

sequenceDiagram
    participant BM as BranchMaintainer
    participant Git as Git
    participant MFB as Merge-Forward Branch
    participant TB as Terminal Branch

    BM->>BM: advanceBranchHereFromMergeForward(targetBranch)
    alt targetBranch === terminalBranch
        BM->>Git: fastForwardTerminalBranch()
        Git->>Git: checkout targetBranch
        Git->>Git: pull origin
        Git->>MFB: merge origin/mergeForwardBranch --no-ff
        MFB->>TB: (merge commit created)
        Git->>Git: push origin targetBranch
        Git-->>BM: success
    else non-terminal branch
        BM->>Git: (existing branch advancement logic)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: merging resolved conflicts into the terminal branch before cleanup, directly addressing issue #43.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem (terminal branch being skipped) and the solution (merging content before deletion).
Linked Issues check ✅ Passed The PR implementation fully addresses issue #43 requirements: it prevents skipping the terminal branch by adding fastForwardTerminalBranch method that merges merge-forward content into main using --no-ff before cleanup.
Out of Scope Changes check ✅ Passed All changes are directly in scope: the new fastForwardTerminalBranch method, updated tests validating terminal branch behavior, and an integration test for the specific issue scenario.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-43-terminal-branch-fast-forward

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/branch-maintainer.js (1)

208-219: Consider renaming fastForwardTerminalBranch.

This helper never fast-forwards; it always creates a --no-ff merge commit. A name that says “merge” would make the call site, logs, and tests less misleading.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/branch-maintainer.js` around lines 208 - 219, The helper
fastForwardTerminalBranch actually always creates a non-fast-forward merge
commit; rename the function to a descriptive name like mergeTerminalBranchNoFF
(or mergeTerminalBranchWithNoFF) and update all references: the declaration
(async fastForwardTerminalBranch), all call sites, related log messages, tests,
and any documentation to use the new name so behavior and names align; ensure
exported identifiers (if any) and JSDoc/comments describing the method are
updated to reflect the new name and that it always uses --no-ff.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/branch-maintainer.js`:
- Around line 208-219: The helper fastForwardTerminalBranch actually always
creates a non-fast-forward merge commit; rename the function to a descriptive
name like mergeTerminalBranchNoFF (or mergeTerminalBranchWithNoFF) and update
all references: the declaration (async fastForwardTerminalBranch), all call
sites, related log messages, tests, and any documentation to use the new name so
behavior and names align; ensure exported identifiers (if any) and
JSDoc/comments describing the method are updated to reflect the new name and
that it always uses --no-ff.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 75df6416-5fac-4028-a1aa-16e7c5c8dd53

📥 Commits

Reviewing files that changed from the base of the PR and between ef0e297 and 8bce313.

📒 Files selected for processing (3)
  • src/branch-maintainer.js
  • test/branch-maintainer-test.js
  • test/real-git-test.js

@mattsgarlata mattsgarlata merged commit 18b41dd into main Mar 25, 2026
2 checks passed
@mattsgarlata mattsgarlata deleted the issue-43-terminal-branch-fast-forward branch March 25, 2026 12:10
* because other PRs may have merged into main while the developer
* was resolving conflicts (making fast-forward impossible).
*/
async fastForwardTerminalBranch(mergeForwardBranch, targetBranch) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function is called fastForwardTerminalBranch, but it's documentation explicitly says "Always creates a merge commit rather than attempting fast-forward". Myabe just mergeToTerminalBranch() instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🤦

thanks for catching that!

mattsgarlata added a commit that referenced this pull request Mar 25, 2026
The method always creates a --no-ff merge commit, so "fast-forward"
was misleading. Addresses PR #44 review feedback from Jerry.

Made-with: Cursor
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.

Resolved conflicts on last hop never reach main

2 participants