Skip to content

feat: add Codeberg/Gitea badge pattern support#9

Merged
GeiserX merged 1 commit into
mainfrom
feat/codeberg-badge-support
May 20, 2026
Merged

feat: add Codeberg/Gitea badge pattern support#9
GeiserX merged 1 commit into
mainfrom
feat/codeberg-badge-support

Conversation

@GeiserX
Copy link
Copy Markdown
Owner

@GeiserX GeiserX commented May 20, 2026

Summary

  • Expand BADGE_PATTERNS from single regex per badge type to a list of alternatives — an entry passes if any pattern matches
  • Add support for shields.io Gitea native endpoints (/gitea/stars/, /gitea/last-commit/, /gitea/license/)
  • Add support for static/dynamic shields.io/badge/ patterns for language and license badges
  • Add TestCodebergBadges test class with 8 new tests covering all badge types

This enables awesome lists to include Codeberg-hosted repos with proper badge validation.

Test plan

  • All 56 tests pass (8 new Codeberg-specific tests)
  • Existing GitHub badge patterns unaffected (backward compatible)
  • Linter validates awesome-spain README with a Codeberg entry successfully

Summary by CodeRabbit

  • Improvements

    • Badge validation now supports multiple URL formats for each badge type, enabling compatibility with Codeberg/Gitea badges alongside existing GitHub badge formats.
  • Tests

    • Added comprehensive test coverage for Codeberg-compatible badge validation, including individual badge type validation and cross-format compatibility checks.

Review Change Stack

Expand badge validation to accept shields.io Gitea endpoints
(stars, last-commit, license) and static/dynamic badges (language,
license) used by Codeberg-hosted repos. Each badge type now accepts
multiple alternative regex patterns — an entry passes if any matches.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

📝 Walkthrough

Walkthrough

Badge pattern validation extended from single regex per type to multiple alternative regexes per type. The BADGE_PATTERNS data structure now maps each badge type to a list of patterns, enabling support for Codeberg/Gitea-compatible shields.io URLs. Validation logic updated to accept badges if any pattern in the list matches. Comprehensive test suite added.

Changes

Badge pattern multi-format support

Layer / File(s) Summary
Badge patterns data structure
lint.py
BADGE_PATTERNS restructured from dict[str, str] to dict[str, list[str]] with multiple alternative shields.io regexes per badge type (stars, last-commit, language, license).
Required badge validation logic
lint.py
Validation updated to iterate over the pattern list for a selected badge type and accept the badge if any pattern matches the entry line.
Codeberg badge test suite
tests/test_lint.py
New TestCodebergBadges class with helpers to generate Codeberg/Gitea badge strings. Test cases verify individual badge type acceptance, all-badges-required scenarios, alternative dynamic-json formats, GitHub pattern backward compatibility, and missing badge detection.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: expanding badge pattern support to include Codeberg/Gitea formats.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/codeberg-badge-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.34%. Comparing base (def4dcd) to head (e39507c).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main       #9   +/-   ##
=======================================
  Coverage   99.34%   99.34%           
=======================================
  Files           1        1           
  Lines         152      153    +1     
=======================================
+ Hits          151      152    +1     
  Misses          1        1           
Files with missing lines Coverage Δ
lint.py 99.34% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/test_lint.py (1)

431-533: ⚡ Quick win

Strengthen positive badge tests by asserting zero lint errors.

These tests currently only check absence of one error message, so unrelated lint failures could slip through. For acceptance-path cases, assert errors == [] instead.

Suggested update pattern
errors = lint_readme(readme, config)
-assert not any("Missing required badge: stars" in e[1] for e in errors)
+assert errors == []
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_lint.py` around lines 431 - 533, The tests that verify acceptance
paths (e.g., test_codeberg_stars_badge_accepted,
test_codeberg_last_commit_badge_accepted, test_codeberg_language_badge_accepted,
test_codeberg_license_badge_accepted,
test_codeberg_license_dynamic_json_accepted, test_github_badges_still_work)
currently only assert absence of a specific "Missing required badge" message;
replace those ad-hoc assertions with a strict equality check to ensure no lint
errors at all by changing their final assertion to assert errors == [] (leave
test_codeberg_all_badges_required_pass as-is).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/test_lint.py`:
- Around line 431-533: The tests that verify acceptance paths (e.g.,
test_codeberg_stars_badge_accepted, test_codeberg_last_commit_badge_accepted,
test_codeberg_language_badge_accepted, test_codeberg_license_badge_accepted,
test_codeberg_license_dynamic_json_accepted, test_github_badges_still_work)
currently only assert absence of a specific "Missing required badge" message;
replace those ad-hoc assertions with a strict equality check to ensure no lint
errors at all by changing their final assertion to assert errors == [] (leave
test_codeberg_all_badges_required_pass as-is).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 893943a6-2394-4b21-b0c1-5347fdbd93b2

📥 Commits

Reviewing files that changed from the base of the PR and between def4dcd and e39507c.

📒 Files selected for processing (2)
  • lint.py
  • tests/test_lint.py

@GeiserX GeiserX merged commit 2b7dff2 into main May 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant