mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-30 12:25:49 +00:00
fix(tools): merge only the pull requests that share files or exports with the branch in pr_overlap
pr_overlap --branch merged every open pull request against main, although a pull request can only appear in the report when it shares a file or an export with the branch, so on a repository with a thousand open pull requests the check did not finish in an hour. probe lists each pull request's files and exports from git diff base...head, without a merge, and scan_all merges only the ones that overlap the branch; the others get empty sets, which is what they would contribute to the report. --out is unchanged.
This commit is contained in:
1 parent
4017310678
commit
4c8e1d194e
1 file changed
+23
-1
+23
-1
@@ -241,9 +241,31 @@ def scan(pr):
|
||||
pr["removed_exports"] = source_changed_exports(diff, "-")
|
||||
|
||||
|
||||
def probe(pr):
|
||||
changes = git("diff", "--name-only", "--no-renames", "-z", f"refs/pr/base...{pr['ref']}").split("\0")
|
||||
files = {path for path in changes if path}
|
||||
if not any(path.startswith("core/libs/prx/") and path.endswith(".cpp") for path in files):
|
||||
return files, set()
|
||||
return files, exports(git("diff", "-U0", "--no-color", f"refs/pr/base...{pr['ref']}", "--", "core/libs/prx/*.cpp"))
|
||||
|
||||
|
||||
def related(prs, executor):
|
||||
mine = prs[0]
|
||||
scan(mine)
|
||||
others = {n: pr for n, pr in prs.items() if n}
|
||||
chosen = {}
|
||||
for (n, pr), (files, found) in zip(others.items(), executor.map(probe, others.values())):
|
||||
if files & mine["files"] or found & mine["exports"]:
|
||||
chosen[n] = pr
|
||||
else:
|
||||
pr.update(tree=None, files=set(), added=set(), exports=set())
|
||||
return chosen
|
||||
|
||||
|
||||
def scan_all(prs, jobs):
|
||||
with ThreadPoolExecutor(max_workers=jobs) as executor:
|
||||
list(executor.map(scan, prs.values()))
|
||||
pending = related(prs, executor) if 0 in prs else prs
|
||||
list(executor.map(scan, pending.values()))
|
||||
|
||||
|
||||
def hunks(pr, path):
|
||||
|
||||
Reference in new issue
Block a user