summaryrefslogtreecommitdiffhomepage
path: root/script
diff options
context:
space:
mode:
authorLuke Parker <[email protected]>2026-03-25 14:45:37 +1000
committerGitHub <[email protected]>2026-03-25 04:45:37 +0000
commit700f57112ab6d2ced3add2021841e22b16f3b0cb (patch)
treebeeac987757f06b384c2166e5b0c2d4b7a045fa7 /script
parent0a80ef4278c252cb8dca72cae5d5c5748cec7e9a (diff)
downloadopencode-700f57112ab6d2ced3add2021841e22b16f3b0cb.tar.gz
opencode-700f57112ab6d2ced3add2021841e22b16f3b0cb.zip
fix: provide merge context to beta conflict resolver (#19055)
Diffstat (limited to 'script')
-rwxr-xr-xscript/beta.ts27
1 files changed, 24 insertions, 3 deletions
diff --git a/script/beta.ts b/script/beta.ts
index 61f9cf862..2c3ed88b0 100755
--- a/script/beta.ts
+++ b/script/beta.ts
@@ -50,11 +50,32 @@ async function cleanup() {
} catch {}
}
-async function fix(pr: PR, files: string[]) {
+async function fix(pr: PR, files: string[], prs: PR[], applied: number[], idx: number) {
console.log(` Trying to auto-resolve ${files.length} conflict(s) with opencode...`)
+
+ const done =
+ prs
+ .filter((x) => applied.includes(x.number))
+ .map((x) => `- #${x.number}: ${x.title}`)
+ .join("\n") || "(none yet)"
+
+ const next =
+ prs
+ .slice(idx + 1)
+ .map((x) => `- #${x.number}: ${x.title}`)
+ .join("\n") || "(none)"
+
const prompt = [
`Resolve the current git merge conflicts while merging PR #${pr.number} into the beta branch.`,
+ `PR #${pr.number}: ${pr.title}`,
`Only touch these files: ${files.join(", ")}.`,
+ `Merged PRs on HEAD:\n${done}`,
+ `Pending PRs after this one (context only):\n${next}`,
+ "IMPORTANT: The conflict resolution must be consistent with already-merged PRs.",
+ "Pending PRs are context only; do not introduce their changes unless they are already present on HEAD.",
+ "Prefer already-merged PRs over the base branch when resolving stacked conflicts.",
+ "If a PR already deleted a file/directory, do not re-add it, instead apply changes in the new semantic location.",
+ "If a PR already changed an import, keep that change.",
"Keep the merge in progress, do not abort the merge, and do not create a commit.",
"When done, leave the working tree with no unmerged files.",
].join("\n")
@@ -99,7 +120,7 @@ async function main() {
const applied: number[] = []
const failed: FailedPR[] = []
- for (const pr of prs) {
+ for (const [idx, pr] of prs.entries()) {
console.log(`\nProcessing PR #${pr.number}: ${pr.title}`)
console.log(" Fetching PR head...")
@@ -119,7 +140,7 @@ async function main() {
const files = await conflicts()
if (files.length > 0) {
console.log(" Failed to merge (conflicts)")
- if (!(await fix(pr, files))) {
+ if (!(await fix(pr, files, prs, applied, idx))) {
await cleanup()
failed.push({ number: pr.number, title: pr.title, reason: "Merge conflicts" })
await commentOnPR(pr.number, "Merge conflicts with dev branch")