Repository navigation
fix(branches): run the merge only once after Start Over (DX-33747) - #391
Conversation
Choosing Start Over (or Go Back for Overwrite with Compare and Ask for Preference) in cm:branches:merge called start() again while the first start() was still waiting. When the second one finished, the first one carried on and ran the chosen action again: another summary export, an entry migration prompt, and a second merge request that failed with "No items available for merge". Each extra Start Over added one more repeat. - restartMergeProcess() now only asks the questions again (collectMergeSettings()), so start() runs the action once. - Remove the enableEntryExp = true set after a plain Execute Merge. It did nothing on a normal run and turned the repeat into an entry migration. - Remove a duplicated executeOption reset. Add tests that run the real menu flow with the prompts stubbed and count exports and merges for each way through the menus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
🟠 High Severity - SLA Breached Issues (with fixes)Showing 1 issue(s) that have exceeded the 30-day SLA threshold:
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
❌ BUILD FAILED - Security checks failed Please review and fix the security vulnerabilities before merging. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
What was wrong
In
csdx cm:branches:merge, picking Start Over didn't really start over. The CLI began a second copy of the merge flow while the first copy was still waiting. When the second copy finished, the first copy woke up and did everything again:Every extra Start Over added one more repeat: 3 Start Overs meant 4 merge requests. Go Back did the same for the "Overwrite with Compare" and "Merge, Ask for Preference" strategies, because their Go Back is routed through the same restart code.
A customer hit this on CLI 2.0.2: the first merge worked, and then the CLI reported a failed second merge they never asked for. Ticket: DX-33747.
What this PR changes
All in
packages/contentstack-branches/src/branch/merge-handler.ts:restartMergeProcess()callscollectMergeSettings()instead ofstart(). The onestart()the command opened then runs the chosen action once, with the latest answers.this.enableEntryExp = trueat the end ofstart()). On a normal run it did nothing because it was set after the merge. During the repeat, it was what caused the surprise entry migration question. @netrajpatel, you added this in23ff7f692. Can you confirm it wasn't meant to be there?executeOption(the same 3 lines appeared twice).Nothing changes for a normal run with no Start Over or Go Back. No flags, API calls or output change.
How it was tested
New unit tests (
test/unit/branch/merge-handler-navigation.test.ts, 16 tests). They run the real menu code with only the prompts and the merge/export calls stubbed, and count what actually happened:--strategy/--merge-actionflags) results in exactly one export and at most one merge13 of the 16 fail on
developmentand all pass with this change. The full package suite passes (152 passing, 1 already skipped), and build and lint are clean.Live runs on a test stack with this build:
Each merge created exactly one revert branch on the stack, so no second merge reached the server.
Notes for reviewers
SKIP_HOOK=1. The Talisman secret scan passed when run on its own. The hook'ssnyk test --all-projects --fail-on=allcurrently fails for every commit in this repo because of 17 existing dependency issues, including 2 criticalcross-spawnissues incontentstack-apps-cli. This PR changes no dependencies. Those issues need their own fix.🤖 Generated with Claude Code