Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): fix saving merge request approval rules #2773

Merged
merged 2 commits into from
May 13, 2024

Conversation

Sjord
Copy link
Contributor

@Sjord Sjord commented Jan 22, 2024

Closes #2548

This seems to work when testing against a GitLab Ultimate test project. I assume that the integration tests run against a Gitlab CE instance, so adding a test for this is not feasible. I am not very sure of the changes I made, but it does seem to work correctly.

Changes

Remove custom code and correctly set identifiers for merge request approvals.

Documentation and testing

Please consider whether this PR needs documentation and tests. This is not required, but highly appreciated:

@Sjord Sjord force-pushed the save-mr-approval-rules branch 2 times, most recently from 7326a77 to a168c63 Compare January 22, 2024 14:51
@JohnVillalovos
Copy link
Member

This seems to work when testing against a GitLab Ultimate test project. I assume that the integration tests run against a Gitlab CE instance, so adding a test for this is not feasible.

FYI: The functional tests run against a GitLab EE instance. So tests should be feasible.

Copy link

codecov bot commented Jan 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.48%. Comparing base (7ec3189) to head (0866a12).
Report is 44 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2773      +/-   ##
==========================================
- Coverage   96.52%   96.48%   -0.05%     
==========================================
  Files          90       90              
  Lines        5872     5862      -10     
==========================================
- Hits         5668     5656      -12     
- Misses        204      206       +2     
Flag Coverage Δ
api_func_v4 82.39% <100.00%> (+0.15%) ⬆️
cli_func_v4 83.65% <100.00%> (+0.07%) ⬆️
unit 88.24% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
gitlab/v4/objects/merge_request_approvals.py 98.48% <100.00%> (-0.27%) ⬇️

... and 1 file with indirect coverage changes

@Sjord
Copy link
Contributor Author

Sjord commented Jan 30, 2024

I at least changed the unit test to have different ids for different entities, so that a mixup in ids would become noticable.

@david-vana-conrad
Copy link

What's the plan with this fix? How can I help to finish it?

@Sjord
Copy link
Contributor Author

Sjord commented Mar 26, 2024

I consider this ready to be merged.

@JohnVillalovos suggested adding functional tests, but I updated the unit tests instead to test this functionality. Is that sufficient?

@david-vana-conrad, perhaps you can test this and confirm that it works correctly, if you have access to a Gitlab Ultimate instance.

@david-vana-conrad
Copy link

@Sjord Your fix works correctly on our GitLab Ultimate instance. Script has changed the Merge Request approval settings as requested.

@jarodwilson
Copy link
Contributor

I've verified that this patch gets our .save() calls to gitlab.com hosted projects working again as well, would like to see it merged so we don't have to run a patched build to support our needs. :)

Sjord added 2 commits May 13, 2024 13:02
The original bug was that the merge request identifier was used instead of the
approval rule identifier. The test didn't notice that because it used `1` for
all identifiers. Make these identifiers different so that a mixup will become
apparent.
@JohnVillalovos JohnVillalovos enabled auto-merge (rebase) May 13, 2024 20:04
@JohnVillalovos JohnVillalovos merged commit c23e6bd into python-gitlab:main May 13, 2024
16 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.

ProjectMergeRequestApprovalRule.save() throws 404
4 participants