Skip to content

feat: show conflicting files and blame in failed-merge comments#416

Merged
harikaduyu merged 5 commits into
mainfrom
feat/conflict-blame-comments
Jun 17, 2026
Merged

feat: show conflicting files and blame in failed-merge comments#416
harikaduyu merged 5 commits into
mainfrom
feat/conflict-blame-comments

Conversation

@harikaduyu

@harikaduyu harikaduyu commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Bugfix
  • Enhancement / new feature
  • Refactoring
  • Documentation

Description

When a dev-branch rebuild fails to merge a PR, the failure comment now lists the specific files that conflicted and, where possible, points at the other dev-labeled PR that was merged earlier in the same run and touched those files.

Key changes:

  • FailedPull carries conflictingFileToPulls: Map<string, Pull[]>, replacing the flat conflictFiles + mergedFirstInThisRun pair. The map is per-file so blame is accurate even when multiple files conflict for different reasons.
  • commentFail receives base + failedPull as parameters; getInput removed from the formatter (boundary fix).
  • Gate simplified to if (mergeResult): failure labels and comments now fire even when no PR merged cleanly, fixing a pre-existing bug where all-fail runs never applied failure labels.
  • updateLabels now receives failedPulls, making success/failed/skipped classification explicit rather than implicit !successful.
  • diff-tree moved outside the merge try/catch so a diff failure cannot incorrectly trigger git merge --abort on an already-successful merge.

Checklist

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Review the Contributing Guideline and sign CLA
  • Reference relevant issue(s) and close them after merging

This PR was created with opencode.

When a dev-branch rebuild fails to merge a PR, the failure comment now
lists the specific files that conflicted and, where possible, points at
the other dev-labeled PR that was merged earlier in the same run and
touched those files.

- FailedPull carries conflictingFileToPulls: Map<string, Pull[]>,
  replacing the flat conflictFiles + mergedFirstInThisRun pair. The map
  is per-file so blame is accurate even when multiple files conflict for
  different reasons.
- commentFail receives base + failedPull as parameters; getInput removed
  from the formatter.
- Gate simplified to `if (mergeResult)`: failure labels and comments now
  fire even when no PR merged cleanly, fixing a pre-existing bug.
- updateLabels receives failedPulls, making the success/failed/skipped
  classification explicit instead of implicit !successful.
- diff-tree moved outside the merge try/catch so a diff failure cannot
  trigger git merge --abort on an already-successful merge.

Co-authored-by: opencode <opencode@noreply.opencode.ai>
Co-authored-by: GitHub Copilot <copilot@noreply.github.com>
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

…for mixed cases

When a conflicting file has no culprit PR (empty pullers list), the
per-file suffix now says 'conflicts with `base` — rebase this PR onto
`base` to resolve' instead of emitting nothing.

The surrounding body copy is reworded to be accurate for mixed cases
(some files blamed on a sibling PR, some on base) — the old copy
falsely implied all conflicts were caused by another dev PR.

Two new unit tests cover the pure base-conflict and mixed cases.

Co-authored-by: opencode <opencode@noreply.opencode.ai>
Co-authored-by: GitHub Copilot <copilot@noreply.github.com>
@harikaduyu

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jun 15, 2026
@harikaduyu harikaduyu marked this pull request as ready for review June 15, 2026 11:53
@harikaduyu harikaduyu requested a review from a team as a code owner June 15, 2026 11:53
@timdittler

Copy link
Copy Markdown
Contributor

Related to #415 ?

@harikaduyu

Copy link
Copy Markdown
Contributor Author

Related to #415 ?

I've worked on this after talking with Kai about this problem, not realizing he's already opened a PR already. 🙈 I have however did a couple of iterations on it myself having an agent review it and feel like was a bit more involved. Sorry that it creates an additional review burden. But yes, it's basically solves the same problem.

@timdittler

Copy link
Copy Markdown
Contributor

@harikaduyu @kaitimmer Can you please decide which PR you would like to move forward?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances AutoDev’s failed-merge notifications by tracking merge-conflict files per failed PR and attributing (“blaming”) conflicts to dev-labeled PRs merged earlier in the same run when possible, then using that data in failure comments and label updates.

Changes:

  • Introduces FailedPull with conflictingFileToPulls: Map<string, Pull[]> and updates failure comment formatting to list conflicting files and per-file “culprit” PRs.
  • Captures git merge stderr to extract conflict paths, records per-merge changed files via git diff-tree, and plumbs failedPulls through comment/label update flows.
  • Adds Vitest coverage for commentFail rendering, label behavior for “skipped” PRs, and conflict-file extraction/plumbing.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.

File Description
src/utils.ts Adds FailedPull, enriches failure comments with per-file conflict attribution, and updates label/comment APIs to accept failedPulls.
src/autodev.ts Captures merge stderr to extract conflicting file paths, builds per-file attribution map across the merge loop, and always returns failed pulls.
src/autodev.test.ts Adds focused tests for commentFail, updateLabels, and failed-merge conflict extraction/attribution plumbing.
dist/index.js Updates built distribution output to reflect the new failure-comment, conflict extraction, and labeling behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils.ts
Comment on lines 198 to 202
if (
(successful && hasSuccessfulLabel) ||
(!successful && hasFailureLabel)
(targetLabel === customSuccessLabel && hasSuccessfulLabel) ||
(targetLabel === customFailureLabel && hasFailureLabel)
) {
continue
Comment thread src/autodev.ts Outdated
Comment on lines +245 to +250
for (const m of stderr.matchAll(
/^CONFLICT \(rename\/rename\): \S+ renamed to (\S+) in \S+ and to (\S+) in/gm
)) {
files.add(m[1].trim())
files.add(m[2].trim())
}

@0x46616c6b 0x46616c6b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a living example? Sometimes it is hard to review without validation. You could use this change in another repository and try to create a conflict.

harikaduyu and others added 3 commits June 16, 2026 16:14
git writes CONFLICT lines to stdout, not stderr.
Capturing only stderr caused extractConflictFiles to
always return an empty list, falling back to the generic
failure comment instead of the blame comment.

Co-authored-by: opencode <opencode@noreply.opencode.ai>
Co-authored-by: GitHub Copilot <copilot@noreply.github.com>
- Drop dead delete/modify regex: git always emits modify/delete
  regardless of which side deleted the file
- Fix rename/rename: extract the original path (what diff-tree records)
  instead of the two target names (which never match fileToPulls)
- Switch diff-tree to -M --name-status to detect renames; index both
  old and new paths so later conflict lookups find the right PR

Co-authored-by: opencode <opencode@noreply.opencode.ai>
Co-authored-by: GitHub Copilot <copilot@noreply.github.com>
diff-tree HEAD after a fast-forward merge shows the incoming commit's
diff against its own parent, not the files that changed vs the pre-merge
state. Snapshot HEAD before the merge and diff against that instead, so
fast-forwarded PRs correctly populate fileToPulls.

Co-authored-by: opencode <opencode@noreply.opencode.ai>
Co-authored-by: GitHub Copilot <copilot@noreply.github.com>
@harikaduyu

Copy link
Copy Markdown
Contributor Author

@0x46616c6b 0x46616c6b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your effort. LGTM.

@harikaduyu harikaduyu merged commit 8efec62 into main Jun 17, 2026
11 checks passed
@harikaduyu harikaduyu deleted the feat/conflict-blame-comments branch June 17, 2026 07:35
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 17, 2026
@0x46616c6b 0x46616c6b added the enhancement New feature or request label Jun 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants