|
| 1 | +--- |
| 2 | +description: "Merge staging into next branch following the Dialtone Next Merge Guide. Use when the user asks to merge staging into next, sync next with staging, or references the merge guide." |
| 3 | +--- |
| 4 | + |
| 5 | +# /merge-next - Merge staging into next |
| 6 | + |
| 7 | +Executes the Dialtone Next Merge Guide: pulls both branches, merges staging into next, resolves conflicts, runs the color-stops migration, commits, builds, and tests. |
| 8 | + |
| 9 | +**Important:** This must be run via `git merge` on the CLI, NOT via a GitHub PR (which would squash and destroy historical references). |
| 10 | + |
| 11 | +## Workflow |
| 12 | + |
| 13 | +### 1. Pull and merge |
| 14 | + |
| 15 | +```bash |
| 16 | +git checkout next |
| 17 | +git pull origin next |
| 18 | +git fetch origin staging:staging # update local staging ref without merging |
| 19 | +git merge --no-commit staging |
| 20 | +``` |
| 21 | + |
| 22 | +Save the list of conflicted files immediately (needed for the verification step later): |
| 23 | + |
| 24 | +```bash |
| 25 | +git diff --name-only --diff-filter=U > /tmp/merge-conflicted-files.txt |
| 26 | +``` |
| 27 | + |
| 28 | +If there are no conflicts, skip to step 4. |
| 29 | + |
| 30 | +### 2. Resolve CHANGELOG conflicts |
| 31 | + |
| 32 | +Run the changelog resolution script first: |
| 33 | + |
| 34 | +```bash |
| 35 | +python3 scripts/resolve-changelog-conflicts.py |
| 36 | +``` |
| 37 | + |
| 38 | +This handles CHANGELOG.json and CHANGELOG.md for the main packages. For any remaining CHANGELOG conflicts (e.g. dialtone-icons, eslint-plugin-dialtone) that the script missed, resolve manually: |
| 39 | + |
| 40 | +- **CHANGELOG.md**: Keep both sides' entries, staging releases first (newest date first), then next prerelease entries, then shared history. |
| 41 | +- **CHANGELOG.json**: Merge both version arrays, staging entries first, sorted by date descending. A quick Node script can help: |
| 42 | + |
| 43 | +```js |
| 44 | +// Extract HEAD and staging JSON from conflict markers, merge versions arrays, |
| 45 | +// sort by date descending, write back. |
| 46 | +``` |
| 47 | + |
| 48 | +Stage all resolved changelogs. |
| 49 | + |
| 50 | +### 3. Resolve remaining conflicts |
| 51 | + |
| 52 | +Apply these resolution strategies: |
| 53 | + |
| 54 | +| Conflict type | Strategy | |
| 55 | +| --- | --- | |
| 56 | +| **package.json versions** | Take staging's released version (higher semver). Next will get its own prerelease versions on next release. | |
| 57 | +| **pnpm-lock.yaml** | Accept staging's version (`git checkout --theirs pnpm-lock.yaml`), then regenerate with `pnpm install --no-frozen-lockfile`. | |
| 58 | +| **Code conflicts** | Analyze both sides. Keep new features from both branches. Prefer next's naming conventions (e.g. `#startIcon` over `#icon`, logical properties over physical). Combine additive changes. | |
| 59 | +| **Documentation conflicts** | Prefer next's unified `code-example` component over staging's older `code-well-header` + `code-example-tabs` pattern. | |
| 60 | +| **CSS conflicts** | Prefer next's logical properties (`max-inline-size` over `max-width`). Combine additive styles from both sides. | |
| 61 | + |
| 62 | +Stage all resolved files. Verify no conflict markers remain: |
| 63 | + |
| 64 | +```bash |
| 65 | +git diff --name-only --diff-filter=U # should be empty |
| 66 | +git diff --cached --name-only | xargs grep -l '<<<<<<<' # should find nothing |
| 67 | +``` |
| 68 | + |
| 69 | +### 4. Run the color-stops migration script |
| 70 | + |
| 71 | +**DO NOT commit yet.** The script needs the repo to be in a merge state. |
| 72 | + |
| 73 | +Preview first: |
| 74 | + |
| 75 | +```bash |
| 76 | +node scripts/merge-migrate-color-stops.mjs --merge-from origin/staging --dry-run --verbose |
| 77 | +``` |
| 78 | + |
| 79 | +Then run for real (pipe `y` to auto-confirm): |
| 80 | + |
| 81 | +```bash |
| 82 | +echo "y" | node scripts/merge-migrate-color-stops.mjs --merge-from origin/staging --verbose |
| 83 | +``` |
| 84 | + |
| 85 | +### 5. Verify conflict resolutions |
| 86 | + |
| 87 | +**DO NOT commit yet.** Present a resolution summary to the user for review. |
| 88 | + |
| 89 | +1. Output a structured resolution summary listing every file that had conflicts and what was done: |
| 90 | + |
| 91 | +``` |
| 92 | +Conflict resolution summary: |
| 93 | +- path/to/file.json: <what was chosen and why> |
| 94 | +- path/to/other.vue: <what was combined from each side> |
| 95 | +``` |
| 96 | + |
| 97 | +2. Show the diff for only the files that had conflicts: |
| 98 | + |
| 99 | +```bash |
| 100 | +cat /tmp/merge-conflicted-files.txt | xargs git diff --cached -- |
| 101 | +``` |
| 102 | + |
| 103 | +3. **Wait for user confirmation** before proceeding to commit. Do not continue until the user approves. |
| 104 | + |
| 105 | +### 6. Commit the merge |
| 106 | + |
| 107 | +```bash |
| 108 | +git commit --no-edit |
| 109 | +``` |
| 110 | + |
| 111 | +This uses the default merge commit message and triggers pre-commit hooks (which may rebuild icons, etc.). |
| 112 | + |
| 113 | +After committing, `git show --cc HEAD` can be used to re-inspect only the conflict resolution decisions at any time. |
| 114 | + |
| 115 | +### 7. Fix any lint issues introduced by the merge |
| 116 | + |
| 117 | +Check for new lint issues and fix them. Common ones: |
| 118 | + |
| 119 | +- Extra blank lines in `.mdx` files (MD012) |
| 120 | +- Unused imports after conflict resolution |
| 121 | + |
| 122 | +Commit fixes separately: |
| 123 | + |
| 124 | +```bash |
| 125 | +git add <fixed-files> |
| 126 | +git commit -m "fix(<scope>): NO-JIRA fix lint issues from staging merge" |
| 127 | +``` |
| 128 | + |
| 129 | +### 8. Build, test, and lint |
| 130 | + |
| 131 | +Run the full production build: |
| 132 | + |
| 133 | +```bash |
| 134 | +pnpm nx run dialtone:build |
| 135 | +``` |
| 136 | + |
| 137 | +Run the storybook and docsite builds and verify they complete successfully: |
| 138 | + |
| 139 | +```bash |
| 140 | +pnpm nx run dialtone-vue:build-storybook |
| 141 | +pnpm nx run dialtone-documentation:build |
| 142 | +``` |
| 143 | + |
| 144 | +Run all tests: |
| 145 | + |
| 146 | +```bash |
| 147 | +pnpm nx run dialtone:test:all |
| 148 | +``` |
| 149 | + |
| 150 | +Run all linters: |
| 151 | + |
| 152 | +```bash |
| 153 | +pnpm nx run dialtone:lint:all |
| 154 | +``` |
| 155 | + |
| 156 | +For any failures, determine if they are **pre-existing** (also fail on staging) or **introduced by the merge**. Only fix merge-introduced issues. Report pre-existing failures to the user. |
| 157 | + |
| 158 | +### 9. Push |
| 159 | + |
| 160 | +Do NOT push automatically. Report the results to the user and wait for confirmation before pushing. |
| 161 | + |
| 162 | +```bash |
| 163 | +git push origin next |
| 164 | +``` |
| 165 | + |
| 166 | +## Notes |
| 167 | + |
| 168 | +- Never create a PR for this merge. Always push the merge commit directly to `next`. |
| 169 | +- The color-stops migration script is temporary for the staging-to-next migration period. |
| 170 | +- Pre-commit hooks may trigger icon rebuilds or other builds during the commit step. This is expected and may take a few minutes. |
0 commit comments