hub4j / github-api

Java API for GitHub
https://github-api.kohsuke.org/
MIT License
1.13k stars 724 forks source link

Add functionality to get active rules for a branch #1897

Closed ihrigb closed 1 month ago

ihrigb commented 1 month ago

Description

Add methods to get all active rules for a branch.

Before submitting a PR:

When creating a PR:

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 98.13084% with 2 lines in your changes missing coverage. Please review.

Project coverage is 81.29%. Comparing base (cab9bbb) to head (f3e03d3).

Files Patch % Lines
...main/java/org/kohsuke/github/GHRepositoryRule.java 98.05% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1897 +/- ## ============================================ + Coverage 81.05% 81.29% +0.24% - Complexity 2442 2450 +8 ============================================ Files 237 238 +1 Lines 7342 7449 +107 Branches 398 400 +2 ============================================ + Hits 5951 6056 +105 - Misses 1145 1146 +1 - Partials 246 247 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ihrigb commented 1 month ago

@bitwiseman I will take care of your suggestions.

As of the Parameter vs. Polymorphism topic I had to thoughts about it as well. The parameter way turned out to be more flexible, if GitHub does any change to the API (not sure, if that would happen with the current version being almost two years old). Using polymorphism would result in weird Java code with instanceof stuff and casting types. Happy to discuss this either way.