From 3b89ed78b360de42f3ac4f57c41d266a8116299a Mon Sep 17 00:00:00 2001 From: RealDiligent Date: Wed, 15 Jul 2026 14:22:24 +0800 Subject: [PATCH] fix: resolve OSS scoring false-reject on merged PRs with null base_ref Skip the base-ref eligibility gate when mirror rows omit base_ref, matching issue-discovery fall-through for pre-backfill data. Co-authored-by: Cursor --- .../oss_contributions/mirror/scoring.py | 13 +++++++------ .../oss_contributions/mirror/test_scoring.py | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/gittensor/validator/oss_contributions/mirror/scoring.py b/gittensor/validator/oss_contributions/mirror/scoring.py index f0256434..d7dcf8b8 100644 --- a/gittensor/validator/oss_contributions/mirror/scoring.py +++ b/gittensor/validator/oss_contributions/mirror/scoring.py @@ -207,14 +207,14 @@ def check_merged_branch_eligibility( issue discovery so both reject the same non-acceptable-branch merges. Returns ``(skip, reason)``. Missing ``default_branch`` falls back to - ``main``; missing ``head_ref``/``head_repo_full_name`` skips the head_ref - check rather than false-positive-blocking on older data. + ``main``; missing ``base_ref``/``head_ref``/``head_repo_full_name`` skip + their respective checks rather than false-positive-blocking on older data. """ additional = repo_config.additional_acceptable_branches or [] acceptable = [default_branch or 'main'] + additional - # base_ref check. - if not branch_matches_pattern(base_ref or '', acceptable): + # base_ref check — skip when absent (pre-backfill mirror data). + if base_ref is not None and not branch_matches_pattern(base_ref, acceptable): return True, (f'PR #{pr_number} merged to {base_ref!r} not in acceptable branches={acceptable}') # head_ref check — block PRs whose source branch is itself an acceptable @@ -251,8 +251,9 @@ def _should_skip_merged_mirror_pr(scored: ScoredPR, repo_config: RepositoryConfi When the mirror response is missing a field (older data predating the schema additions), some checks fall through rather than false-positive- - blocking. Concretely: missing ``head_ref`` or ``head_repo_full_name`` skips - the head_ref check. Missing ``default_branch`` falls back to ``main``. + blocking. Concretely: missing ``base_ref`` skips the base_ref check; + missing ``head_ref`` or ``head_repo_full_name`` skips the head_ref check. + Missing ``default_branch`` falls back to ``main``. """ pr = scored.pr diff --git a/tests/validator/oss_contributions/mirror/test_scoring.py b/tests/validator/oss_contributions/mirror/test_scoring.py index 10160023..d94647d2 100644 --- a/tests/validator/oss_contributions/mirror/test_scoring.py +++ b/tests/validator/oss_contributions/mirror/test_scoring.py @@ -54,7 +54,7 @@ def _pr( author_login: str = 'bittoby', merged_by_login: str | None = 'anderdc', author_association: str = 'CONTRIBUTOR', - base_ref: str = 'main', + base_ref: str | None = 'main', head_ref: str | None = 'feature/foo', head_repo_full_name: str | None = 'entrius/gittensor-ui', default_branch: str | None = 'main', @@ -276,6 +276,23 @@ def test_null_head_ref_skips_check(self): ) assert skip is False + def test_null_base_ref_skips_check(self): + # Pre-backfill mirror rows omit base_ref; parity with issue discovery. + scored = ScoredPR( + pr=_pr( + base_ref=None, + default_branch='main', + head_ref='feature/foo', + head_repo_full_name='entrius/gittensor-ui', + ) + ) + skip, reason = _should_skip_merged_mirror_pr( + scored, + _config(additional_branches=['test', 'staging']), + ) + assert skip is False + assert reason is None + def test_null_head_repo_full_name_skips_check(self): # Pre-schema mirror rows may have NULL head_repo_full_name — we can't # distinguish same-repo from fork, so fall through conservatively.