[PR #2349] scripts: pr_overlap.py lists the open pull requests that change the same files (PR-OVERLAP-CHECK) #2355

Open
opened 2026-11-26 21:20:58 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2349
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: feat/pr-overlap-check


📝 Commits (1)

  • a3184a4 scripts: pr_overlap.py lists the open pull requests that change the same files (PR-OVERLAP-CHECK)

📊 Changes

4 files changed (+744 additions, -0 deletions)

View changed files

📝 AGENTS.md (+4 -0)
📝 CONTRIBUTING.md (+5 -0)
➕ scripts/pr_overlap.py (+330 -0)
➕ tests/test_pr_overlap.py (+405 -0)

📄 Description

Claimed in the coordination issue as: PR-OVERLAP-CHECK (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194375468)

Depends on: none. It merges cleanly with the two open pull requests that change the same files (#2103 in AGENTS.md, #2151 in AGENTS.md and CONTRIBUTING.md), as the script itself reports.

What and why

There is no working way to find the open pull requests that touch a file. GitHub's search does not match pull requests by path: the VIEWER-HUNT finding in the coordination issue records gh search prs 'path:viewer/' returning nothing while four open pull requests changed those files. With about 1,490 pull requests open, reading them is not an option, so work gets written twice, and the template's Depends on: line (every pull request this one builds on or conflicts with) is filled in from memory.

scripts/pr_overlap.py asks git instead, with no API call and no token:

  • The open pull requests are the ones the remote has a refs/pull/N/merge for. GitHub keeps that ref while a pull request is open: git ls-remote showed 1,485 of them today (of 2,283 pull request heads), against 1,484 open pull requests in the search API, 317 of them labeled needs rebase.
  • Their heads are fetched into refs/pr-overlap/N, a namespace of the tool. Refs of pull requests that are no longer open are deleted, so the namespace is the open set as of the last run and --no-fetch works offline.
  • A pull request's files are those that differ between its head and its merge base with --base (default origin/main), so what main changed since it branched is not counted as its own. A rename counts as both paths.

python -I scripts/pr_overlap.py <file or folder>... lists the open pull requests that change those paths: the check to run before starting on a file. With no argument it takes the branch's own files (committed against the merge base, plus what is modified or untracked in the working tree) and says how the branch stands to each pull request that changes one of them: clean or conflict from git merge-tree, with the conflicting files, same for the branch's own pull request, included for one the branch is built on. --json gives the same as one object.

It writes refs under refs/pr-overlap/ and nothing else: no tags, no FETCH_HEAD, and no pull request code is checked out or run. AGENTS.md and CONTRIBUTING.md name it where they ask to check the open pull requests.

What it found on real branches here:

  • On #2114 (scripts/run_semantic_tests.py), whose description names one conflicting pull request, it lists 21 open pull requests on the same three files, 8 of which conflict with that branch.
  • On this branch it first reported a conflict with #2151 in AGENTS.md. I moved my paragraph to the end of that section, and it now reports both pull requests as clean.
  • For viewer/serve.py it lists none, which is what the VIEWER-HUNT finding concluded by hand.

Tested

Windows 11, Python 3.14.7, git 2.55.0:

  • python -I tests/test_pr_overlap.py: 19 tests on throwaway repositories, an "upstream" with refs/pull/N/head and refs/pull/N/merge laid out as GitHub does and a clone of it. They cover paths and folders, closed pull requests left out, files measured from the merge base, renames, paths relative to the current folder and with spaces and non-ASCII names, the branch mode with committed, modified and untracked files, the four standings, the kept refs following the open set, --no-fetch with the remote gone, a fork as origin, a shallow clone, and the errors.
  • The test file fails on main, where the script does not exist.
  • 43 one-line changes to the script (heads taken from the merge refs, a two-dot diff, a prefix match without the slash, kept tags, and so on) each make at least one test fail.
  • On this repository: a run takes about 5 s for 1,492 open pull requests with 16 git processes at a time, --no-fetch about 4.6 s. The first run fetched 1,487 heads and took 12 s, in a clone that already had most of their objects from an earlier fetch of the pull request refs; a clone without them will take longer.
  • python -I on tests/test_tool_stdout_encoding.py, tests/test_text_write_line_endings.py, tests/test_ci_registration.py, the 13 tests/test_docs_*.py and tests/test_i18n_index.py; python -I scripts/check_no_game_data.py on the four changed files.
  • Not tested: Linux and macOS (the script and its tests use only git and the standard library, but I ran them on Windows), Python 3.12, which CI runs (contextlib.chdir in the test needs 3.11), a git older than 2.55 (2.29 for fetch --stdin and 2.38 for merge-tree --write-tree are from git's release notes, not from a run), and a host other than GitHub (the merge-ref rule is GitHub's).

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator rule in this change.)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2349 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/pr-overlap-check` --- ### 📝 Commits (1) - [`a3184a4`](https://github.com/ubiquitarianism/leonida/commit/a3184a4755513ed6d0beceeb07439a25cf38dbd5) scripts: pr_overlap.py lists the open pull requests that change the same files (PR-OVERLAP-CHECK) ### 📊 Changes **4 files changed** (+744 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `AGENTS.md` (+4 -0) 📝 `CONTRIBUTING.md` (+5 -0) ➕ `scripts/pr_overlap.py` (+330 -0) ➕ `tests/test_pr_overlap.py` (+405 -0) </details> ### 📄 Description Claimed in the coordination issue as: PR-OVERLAP-CHECK (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194375468) Depends on: none. It merges cleanly with the two open pull requests that change the same files (#2103 in `AGENTS.md`, #2151 in `AGENTS.md` and `CONTRIBUTING.md`), as the script itself reports. ### What and why There is no working way to find the open pull requests that touch a file. GitHub's search does not match pull requests by path: the VIEWER-HUNT finding in the coordination issue records `gh search prs 'path:viewer/'` returning nothing while four open pull requests changed those files. With about 1,490 pull requests open, reading them is not an option, so work gets written twice, and the template's `Depends on:` line (every pull request this one builds on or conflicts with) is filled in from memory. `scripts/pr_overlap.py` asks git instead, with no API call and no token: - The open pull requests are the ones the remote has a `refs/pull/N/merge` for. GitHub keeps that ref while a pull request is open: `git ls-remote` showed 1,485 of them today (of 2,283 pull request heads), against 1,484 open pull requests in the search API, 317 of them labeled `needs rebase`. - Their heads are fetched into `refs/pr-overlap/N`, a namespace of the tool. Refs of pull requests that are no longer open are deleted, so the namespace is the open set as of the last run and `--no-fetch` works offline. - A pull request's files are those that differ between its head and its merge base with `--base` (default `origin/main`), so what `main` changed since it branched is not counted as its own. A rename counts as both paths. `python -I scripts/pr_overlap.py <file or folder>...` lists the open pull requests that change those paths: the check to run before starting on a file. With no argument it takes the branch's own files (committed against the merge base, plus what is modified or untracked in the working tree) and says how the branch stands to each pull request that changes one of them: `clean` or `conflict` from `git merge-tree`, with the conflicting files, `same` for the branch's own pull request, `included` for one the branch is built on. `--json` gives the same as one object. It writes refs under `refs/pr-overlap/` and nothing else: no tags, no `FETCH_HEAD`, and no pull request code is checked out or run. `AGENTS.md` and `CONTRIBUTING.md` name it where they ask to check the open pull requests. What it found on real branches here: - On #2114 (`scripts/run_semantic_tests.py`), whose description names one conflicting pull request, it lists 21 open pull requests on the same three files, 8 of which conflict with that branch. - On this branch it first reported a conflict with #2151 in `AGENTS.md`. I moved my paragraph to the end of that section, and it now reports both pull requests as clean. - For `viewer/serve.py` it lists none, which is what the VIEWER-HUNT finding concluded by hand. ### Tested Windows 11, Python 3.14.7, git 2.55.0: - `python -I tests/test_pr_overlap.py`: 19 tests on throwaway repositories, an "upstream" with `refs/pull/N/head` and `refs/pull/N/merge` laid out as GitHub does and a clone of it. They cover paths and folders, closed pull requests left out, files measured from the merge base, renames, paths relative to the current folder and with spaces and non-ASCII names, the branch mode with committed, modified and untracked files, the four standings, the kept refs following the open set, `--no-fetch` with the remote gone, a fork as `origin`, a shallow clone, and the errors. - The test file fails on `main`, where the script does not exist. - 43 one-line changes to the script (heads taken from the merge refs, a two-dot diff, a prefix match without the slash, kept tags, and so on) each make at least one test fail. - On this repository: a run takes about 5 s for 1,492 open pull requests with 16 git processes at a time, `--no-fetch` about 4.6 s. The first run fetched 1,487 heads and took 12 s, in a clone that already had most of their objects from an earlier fetch of the pull request refs; a clone without them will take longer. - `python -I` on `tests/test_tool_stdout_encoding.py`, `tests/test_text_write_line_endings.py`, `tests/test_ci_registration.py`, the 13 `tests/test_docs_*.py` and `tests/test_i18n_index.py`; `python -I scripts/check_no_game_data.py` on the four changed files. - Not tested: Linux and macOS (the script and its tests use only git and the standard library, but I ran them on Windows), Python 3.12, which CI runs (`contextlib.chdir` in the test needs 3.11), a git older than 2.55 (2.29 for `fetch --stdin` and 2.38 for `merge-tree --write-tree` are from git's release notes, not from a run), and a host other than GitHub (the merge-ref rule is GitHub's). GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator rule in this change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2355
No description provided.