Computes a size label (XS to XL) for a pull request based on changed files, excluding lock and generated files.
#!/usr/bin/env python3
# Source: https://github.com/omnigent-ai/omnigent | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Compute a ``size/{XS,S,M,L,XL}`` label for a PR from its changed files.
Reads the GitHub ``pulls/{n}/files`` JSON array on stdin (objects with
``filename``, ``additions``, ``deletions``) and prints the size label. Lock
and generated files are excluded so a dependency bump does not inflate the
size. Pure stdlib so it runs without an install and is unit-tested directly.
"""
from __future__ import annotations
import json
import re
import sys
# Files whose churn should not count toward review size.
GENERATED = (
re.compile(r"^uv\.lock$"),
re.compile(r"
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key