Skip to content

Commit 4297f9a

Browse files
committed
Revert "Improve conflict resolver bundle"
This reverts commit dc0921a.
1 parent dc0921a commit 4297f9a

1 file changed

Lines changed: 6 additions & 62 deletions

File tree

.github/scripts/pr-triage/resolve_conflicts.py

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
)
2222

2323

24-
CONFLICT_STAGES = ((1, "base"), (2, "ours-head"), (3, "theirs-merge-head"))
25-
26-
2724
def parse_args() -> argparse.Namespace:
2825
parser = argparse.ArgumentParser(description=__doc__)
2926
parser.add_argument("pr", type=int, help="pull request number")
@@ -34,71 +31,21 @@ def parse_args() -> argparse.Namespace:
3431
return parser.parse_args()
3532

3633

37-
def safe_conflict_name(path: str) -> str:
38-
return path.replace("/", "__").replace("\\", "__")
39-
40-
41-
def write_stage_snapshot(directory: Path, path: str, summary: Summary) -> list[str]:
42-
stage_paths: list[str] = []
43-
for stage, label in CONFLICT_STAGES:
44-
result = git(["show", f":{stage}:{path}"], summary, check=False)
45-
if result.returncode != 0:
46-
continue
47-
snapshot_path = directory / f"{safe_conflict_name(path)}.{label}"
48-
snapshot_path.write_text(result.stdout, encoding="utf-8")
49-
stage_paths.append(str(snapshot_path))
50-
return stage_paths
51-
52-
5334
def write_conflict_bundle(directory: Path, summary: Summary) -> Path:
5435
progress(f"Preparing merge conflict bundle in {directory}")
5536
directory.mkdir(parents=True, exist_ok=True)
5637
files = unmerged_paths(summary)
57-
staged_versions_dir = directory / "staged-versions"
58-
staged_versions_dir.mkdir(parents=True, exist_ok=True)
59-
60-
conflicts: list[dict[str, object]] = []
38+
write_json(directory / "conflicts.json", {"files": files})
6139
(directory / "status.txt").write_text(git(["status", "--porcelain"], summary).stdout, encoding="utf-8")
6240
(directory / "head-log.txt").write_text(git(["log", "--oneline", "-n", "20", "HEAD"], summary).stdout, encoding="utf-8")
6341
(directory / "merge-head-log.txt").write_text(git(["log", "--oneline", "-n", "20", "MERGE_HEAD"], summary).stdout, encoding="utf-8")
6442
for path in files:
65-
safe_name = safe_conflict_name(path)
66-
diff_path = directory / f"{safe_name}.diff"
67-
diff_path.write_text(git(["diff", "--", path], summary).stdout, encoding="utf-8")
68-
conflicts.append(
69-
{
70-
"path": path,
71-
"conflict_diff": str(diff_path),
72-
"stage_snapshots": write_stage_snapshot(staged_versions_dir, path, summary),
73-
}
74-
)
75-
write_json(directory / "conflicts.json", {"files": conflicts})
43+
safe_name = path.replace("/", "__").replace("\\", "__")
44+
(directory / f"{safe_name}.diff").write_text(git(["diff", "--", path], summary).stdout, encoding="utf-8")
7645
plan = directory / "conflict-plan.md"
7746
lines = ["# Merge Conflict Resolution Plan", "", "## Conflicted Files", ""]
78-
for conflict in conflicts:
79-
lines.append(f"- {conflict['path']}")
80-
lines.append(f" - Conflict diff: {conflict['conflict_diff']}")
81-
for stage_snapshot in conflict["stage_snapshots"]:
82-
lines.append(f" - Stage snapshot: {stage_snapshot}")
83-
lines.extend(
84-
[
85-
"",
86-
"## Context",
87-
"",
88-
f"- Status: {directory / 'status.txt'}",
89-
f"- HEAD log: {directory / 'head-log.txt'}",
90-
f"- MERGE_HEAD log: {directory / 'merge-head-log.txt'}",
91-
"",
92-
"## Resolution Checklist",
93-
"",
94-
"- Inspect each conflict diff and all available stage snapshots before editing.",
95-
"- Identify what behavior HEAD changed and what behavior MERGE_HEAD changed.",
96-
"- Preserve both behaviors when they can coexist.",
97-
"- If one side is intentionally dropped, record why it is obsolete or incompatible.",
98-
"- After editing, compare the resolved file against both sides before staging it.",
99-
"",
100-
]
101-
)
47+
lines.extend(f"- {path}" for path in files)
48+
lines.extend(["", "## Context", "", f"- Status: {directory / 'status.txt'}", f"- HEAD log: {directory / 'head-log.txt'}", f"- MERGE_HEAD log: {directory / 'merge-head-log.txt'}", ""])
10249
plan.write_text("\n".join(lines), encoding="utf-8")
10350
summary.temp_dir = str(directory)
10451
return plan
@@ -118,10 +65,7 @@ def copilot_prompt(plan_path: Path) -> str:
11865
- Do not push.
11966
- Do not rebase, abort, restart, or use force operations.
12067
- Resolve only the conflicted files listed in the bundle.
121-
- For each conflicted file, inspect the conflict diff plus the available stage snapshots before editing: base, ours-HEAD, and theirs-MERGE_HEAD.
122-
- Preserve the intent of both HEAD and MERGE_HEAD when they can coexist; do not remove helpers, validation, generated bundle content, tests, or workflow steps from either side unless they are clearly obsolete after the merge.
123-
- If you choose one side over the other, explain why the dropped side is incompatible or superseded.
124-
- After editing each file, compare the resolved result against both side snapshots before staging it.
68+
- Preserve the intent of both HEAD and MERGE_HEAD when they can coexist.
12569
- If the conflict requires product judgment or involves binary/non-text files, stop and explain.
12670
- Stage only files that you resolved.
12771
- When done, print a concise summary of each resolved file.

0 commit comments

Comments
 (0)