fix: only compare PRs targeting the same base branch#81
Merged
Conversation
jmeridth
approved these changes
May 1, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes false-positive conflict detection for stacked PRs by ensuring overlap checks only compare pull requests that target the same base branch.
Changes:
- Update
find_file_overlaps()to index by(base_branch, filename)rather than onlyfilename. - Extend unit tests to cover different-base-branch and stacked-PR scenarios.
- Loosen pylint’s
max-module-lineslimit to accommodate the expanded test module.
Show a summary per file
| File | Description |
|---|---|
conflict_detector.py |
Restricts file/line overlap comparisons to PRs sharing the same base branch. |
test_conflict_detector.py |
Adds coverage for cross-base-branch and stacked-PR cases; extends PR test helper to allow base/head branches. |
.github/linters/.python-lint |
Increases allowed Python module length to avoid lint failures with the enlarged test file. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 2
Previously, the conflict detector compared all open PRs against each other regardless of their target branch. This caused false positives for stacked PRs where PR `b` targets branch `a` and PR `a` targets `main` — they naturally touch the same files but cannot conflict at merge time since they target different branches. The fix indexes PRs by (base_branch, filename) so only PRs targeting the same base branch are compared for overlapping line changes. Fixes #78 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Zack Koppert <zkoppert@github.com>
Guard against potential None value in base_branch when indexing file overlaps, ensuring consistent grouping behavior even if PullRequestData is constructed without a base_branch value. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Zack Koppert <zkoppert@github.com>
59f4a30 to
479a0e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Stacked PRs (where PR
btargets branchaand PRatargetsmain) are incorrectly flagged as conflicting because they naturally touch the same files. However, they cannot conflict at merge time since they target different branches.Fixes #78
Impact
In large monorepos where this is being used, 8-11% of open PRs target a non-default branch. These PRs are candidates for false-positive conflict reports under the old logic. This fix eliminates that entire class of false positives.
What changed
Modified
find_file_overlaps()inconflict_detector.pyto index PRs by(base_branch, filename)instead of justfilename. This ensures only PRs targeting the same base branch are compared for overlapping line changes.Before vs After
b→ brancha, PRa→main(stacked)maintouching same linesTradeoffs
Chosen approach: Index by
(base_branch, filename)tuple in the file overlap detection.Alternative considered: Explicit stacked-PR detection by checking if one PR's head branch equals another PR's base branch. Rejected because: (1) it's redundant after the base-branch equality guard, and (2) branch-name equality isn't a reliable model for all stacking workflows.
Testing
DRY_RUN=true:Rollout
Low-risk change — the logic only adds a tighter filter to an existing comparison. PRs that previously conflicted correctly will continue to conflict (same base branch). The only behavioral change is eliminating false positives for cross-base-branch comparisons.
What to watch after merge: If users report missed conflicts, verify whether the involved PRs target the same base branch. The fix intentionally skips cross-base-branch comparisons.