Skip to content

feat!: Add support for pagination options in rules API methods - #3562

Merged
gmlewis merged 3 commits into
google:masterfrom
ktruedat:add-pagination-options-to-rules-apis
Apr 28, 2025
Merged

feat!: Add support for pagination options in rules API methods#3562
gmlewis merged 3 commits into
google:masterfrom
ktruedat:add-pagination-options-to-rules-apis

Conversation

@ktruedat

@ktruedatktruedat commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

BREAKING CHANGE: GetRulesForBranch, GetAllRulesets, and GetAllRepositoryRulesets now accept opts.

Updated GetRulesForBranch, GetAllRulesets, and GetAllRepositoryRulesets methods to accept optional pagination parameters (ListOptions). Enhanced test cases to validate the use of these parameters in API requests.

Fixes: #3560

Updated `GetRulesForBranch`, `GetAllRulesets`, and `GetAllRepositoryRulesets` methods to accept optional pagination parameters (`ListOptions`). Enhanced test cases to validate the use of these parameters in API requests.
@gmlewisgmlewis changed the title Add support for pagination options in rules API methodsfeat!: Add support for pagination options in rules API methodsApr 24, 2025
@gmlewisgmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Apr 24, 2025
@codecov

codecovBot commented Apr 24, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.24%. Comparing base (6a7684f) to head (3d1050a).
Report is 6 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #3562 +/- ##
==========================================
+ Coverage 91.23% 91.24% +0.01% 
==========================================
Files 183 183 Lines 16053 16075 +22 ==========================================
+ Hits 14646 14668 +22 
Misses 1231 1231 Partials 176 176 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please make sure to run the scripts mentioned in step 4 of CONTRIBUTING.md and push the changes (not force-push) to this PR. Thank you!

Comment threadgithub/repos_rules.go

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, to fix the CodeCov issues, please add testBadOptions to your new tests. You can see examples in other locations.

Comment threadgithub/repos_rules.go

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @ktruedat!
LGTM.

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

@stevehipwell - might you have time for a code review? Thank you!

@stevehipwellstevehipwell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we not want tests to cover the case where we set opts to nil? I'd have assumed that the existing tests would use nil and new tests would have been added for the pagination pattern?

@gmlewis

Copy link
Copy Markdown
Collaborator

Testing with opts being nil sounds like a good idea in this case.
In the general case, that would be uninteresting, but it would probably be good to show it, although we still can't see how GitHub interprets the missing query parameter... so I'm fine either way.

@stevehipwell

Copy link
Copy Markdown
Contributor

@gmlewis wouldn't testing without opts catch a regression with the method where it no longer supported nil?

@gmlewis

Copy link
Copy Markdown
Collaborator

@gmlewis wouldn't testing without opts catch a regression with the method where it no longer supported nil?

Yes, great idea. I like it. Thank you, @stevehipwell!
@ktruedat - could you please add that to this PR?

@ktruedat

Copy link
Copy Markdown
ContributorAuthor

@gmlewis of course! I actually wanted to do separate tests from the start but wasn't sure about it. Will add them in a few

@ktruedat

Copy link
Copy Markdown
ContributorAuthor

@gmlewis@stevehipwell I included separate tests with ListOptions for every modified operation. I didn't include the full mock response in the client response since we are not really interested in the response itself, but rather testing the existence of the query params. Let me know if that's okay, thanks!

@stevehipwellstevehipwell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ktruedat is there a reason the enterprise rules have been excluded from these changes? Sorry I'm only just picking this up now, but I thought I'd already checked this.

@ktruedat

Copy link
Copy Markdown
ContributorAuthor

@ktruedat is there a reason the enterprise rules have been excluded from these changes? Sorry I'm only just picking this up now, but I thought I'd already checked this.

@stevehipwell If you are referring to the rules in enterprise_rules.go, there are no list endpoints there, and the documentation also does not mention a ListEnterpriseRules endpoint. Therefore, there is nothing to change.
image

@stevehipwellstevehipwell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@gmlewis

Copy link
Copy Markdown
Collaborator

Thank you, @stevehipwell!
Merging.

@gmlewisgmlewis removed the NeedsReview PR is awaiting a review before merging. label Apr 28, 2025
@gmlewis
gmlewis merged commit bdd7396 into google:masterApr 28, 2025
@ktruedat

Copy link
Copy Markdown
ContributorAuthor

Thank you so much @gmlewis and @stevehipwell , I am glad I could help here! Also, if there are any other open issues that can be fixed, feel free to reach out to me, I am more than happy to contribute to this amazing repository!

@gmlewis

Copy link
Copy Markdown
Collaborator

Thank you so much @gmlewis and @stevehipwell , I am glad I could help here! Also, if there are any other open issues that can be fixed, feel free to reach out to me, I am more than happy to contribute to this amazing repository!

Thank you, @ktruedat! You are welcome to contribute to any open unassigned issue. We welcome all contributions!

jlaportebot added a commit to jlaportebot/go-github that referenced this pull request Jun 28, 2026
…e#3562)
BREAKING CHANGE: `GetRulesForBranch`, `GetAllRulesets`, and `GetAllRepositoryRulesets` now accept `opts`.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API ChangePR will require a bump to the major version num in next release. Look here to see the change(s).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ListOptions missing from GetAllOrganizationRulesets, Repositories.GetAllRulesets, Repositories.GetRulesForBranch functions

3 participants

@ktruedat@gmlewis@stevehipwell