Skip to content

Commit 5e0a0c7

Browse files
authored
Prefer stable version for docs app conflicts in backport workflow (#1791)
* Prefer stable version for docs app conflicts in backport workflow After #1786 restored a minimal Next.js placeholder docs app on stable, docs app conflicts should resolve to the stable branch version rather than being deleted. Only docs/content/ is actively maintained on stable, so conflicts there should still be resolved normally. Update both the auto-resolution logic in backport.yml and the AI prompt to reflect the new policy, and update AGENTS.md to match. * Use git show :2:$file to detect ours-side presence in conflicts git ls-files --error-unmatch succeeds for unmerged paths even when the file only exists on the incoming (theirs) side, which would then fail on git checkout --ours. Use git show :2:$file to specifically check for a stage-2 entry, which indicates the file exists on the ours (stable) side.
1 parent 69af0c1 commit 5e0a0c7

2 files changed

Lines changed: 25 additions & 12 deletions

File tree

.github/workflows/backport.yml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,22 @@ jobs:
4747
echo "status=clean" >> "$GITHUB_OUTPUT"
4848
echo "cherry_pick_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
4949
else
50-
# The docs app is not maintained on the stable branch (only
51-
# docs/content/ is kept for npm prepack scripts). Auto-resolve
52-
# any non-content docs/ conflicts by deleting the files.
50+
# The docs app on the stable branch is a minimal placeholder —
51+
# only docs/content/ is actively maintained (markdown files
52+
# bundled into npm packages via prepack scripts). Auto-resolve
53+
# any non-content docs/ conflicts by keeping the stable branch
54+
# version (discarding the incoming change from main).
5355
git diff --name-only --diff-filter=U | grep '^docs/' | grep -v '^docs/content/' | while IFS= read -r file; do
54-
echo "Auto-resolving docs conflict (deleting): $file"
55-
git rm -f -- "$file"
56+
echo "Auto-resolving docs conflict (keeping stable version): $file"
57+
# Check for a stage-2 ("ours") entry in the index, which means
58+
# the file exists on the stable side of the conflict. Otherwise
59+
# the file was newly added on main and we drop it.
60+
if git show ":2:$file" >/dev/null 2>&1; then
61+
git checkout --ours -- "$file"
62+
git add -- "$file"
63+
else
64+
git rm -f -- "$file"
65+
fi
5666
done || true
5767
5868
# Lockfile conflicts can be resolved by re-running pnpm install,
@@ -110,11 +120,14 @@ jobs:
110120
PR title: $PR_TITLE
111121
Commit message: $COMMIT_MSG
112122
113-
IMPORTANT: Only docs/content/ exists on the stable branch (the rest
114-
of the docs app is removed). If any remaining conflicts involve files
115-
under docs/ that are NOT in docs/content/, resolve them by deleting
116-
the file with "git rm". Conflicts in docs/content/ should be resolved
117-
normally (these are markdown files bundled into npm packages).
123+
IMPORTANT: On the stable branch, only docs/content/ is actively
124+
maintained (markdown files bundled into npm packages). The rest of
125+
the docs app is a minimal placeholder. If any remaining conflicts
126+
involve files under docs/ that are NOT in docs/content/, resolve
127+
them by keeping the stable branch version (the <<<<<<< HEAD side)
128+
and discarding the incoming change from main. If the file does not
129+
exist on the stable side (HEAD side is empty), remove it with
130+
"git rm". Conflicts in docs/content/ should be resolved normally.
118131
119132
Resolve all merge conflicts in the working tree. The content between
120133
<<<<<<< HEAD and ======= is the current stable branch. The content between

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ This repository uses a dual-branch release model with [changesets](https://githu
173173

174174
Both branches trigger the release workflow (`.github/workflows/release.yml`) on push. The changesets action creates a "Version Packages" PR on each branch when there are pending changesets.
175175

176-
**Important:** The docs app (everything under `docs/` except `docs/content/`) is **not maintained on the `stable` branch**. Documentation is deployed only from `main`. The `docs/content/` directory is kept on `stable` because the markdown files are bundled into npm packages via `prepack` scripts. When backporting changes to `stable`, any conflicts involving docs app files (outside of `docs/content/`) should be resolved by deleting the conflicting files. Conflicts in `docs/content/` should be resolved normally. The backport GitHub Action handles this automatically.
176+
**Important:** On the `stable` branch, only `docs/content/` is actively maintained the rest of the docs app is a minimal placeholder. Documentation is deployed only from `main`. The `docs/content/` directory is kept on `stable` because the markdown files are bundled into npm packages via `prepack` scripts. When backporting changes to `stable`, any conflicts involving docs app files (outside of `docs/content/`) should be resolved by keeping the `stable` branch version (discarding the incoming change from `main`). Conflicts in `docs/content/` should be resolved normally. The backport GitHub Action handles this automatically.
177177

178178
### Changesets
179179

@@ -192,7 +192,7 @@ Both branches trigger the release workflow (`.github/workflows/release.yml`) on
192192

193193
To backport a change from `main` to `stable`, add the `backport-stable` label to the PR on `main`. A GitHub Action (`.github/workflows/backport.yml`) will automatically cherry-pick the squashed commit to `stable`. The label can be added before or after merging — the action triggers on both merge and label events. The changeset file is included in the cherry-pick, so the correct semver bump type is preserved on `stable`.
194194

195-
If the cherry-pick fails due to conflicts, the action first auto-resolves any docs app conflicts (files under `docs/` except `docs/content/`, since the docs app is not maintained on `stable`) and `pnpm-lock.yaml` conflicts (by re-running `pnpm install`). If those resolve everything, the cherry-pick is pushed directly to `stable`. Otherwise, it attempts to resolve remaining conflicts using [opencode](https://opencode.ai) (AI-powered conflict resolution). If successful, it creates a PR targeting `stable` for human review instead of pushing directly. If the AI cannot resolve the conflicts, the action will comment on the original PR with instructions for manual resolution.
195+
If the cherry-pick fails due to conflicts, the action first auto-resolves any docs app conflicts (files under `docs/` except `docs/content/`) by keeping the `stable` branch version, since the docs app is a minimal placeholder on `stable` and not actively maintained there. It also auto-resolves `pnpm-lock.yaml` conflicts by re-running `pnpm install`. If those resolve everything, the cherry-pick is pushed directly to `stable`. Otherwise, it attempts to resolve remaining conflicts using [opencode](https://opencode.ai) (AI-powered conflict resolution). If successful, it creates a PR targeting `stable` for human review instead of pushing directly. If the AI cannot resolve the conflicts, the action will comment on the original PR with instructions for manual resolution.
196196

197197
### Pre-release Lifecycle
198198

0 commit comments

Comments
 (0)