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: GitLab - use "approvals_left" instead of "approvals_before_merge" when checking if pull is mergeable #5049

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

CaioAugustoo
Copy link
Contributor

@CaioAugustoo CaioAugustoo commented Oct 31, 2024

what

Currently, Atlantis uses the approvals_before_merge field on GitLab client in order to check if MR is mergeable. But using that field is not correctly because approvals_before_merge is the configured number of approvals required for the MR and not the remaining number of approvals.

This PR will fix that. Also, there is a related issue here.

why

In cases that GitLab users updates the approvals_before_merge on any MR, Atlantis will throw Apply Failed: Pull request must be mergeable before running apply. error. You can read more here.

tests

Tested locally

references

Relates to #4949

@CaioAugustoo CaioAugustoo requested review from a team as code owners October 31, 2024 02:54
@CaioAugustoo CaioAugustoo requested review from GenPage, lukemassa and nitrocode and removed request for a team October 31, 2024 02:54
@github-actions github-actions bot added go Pull requests that update Go code provider/gitlab labels Oct 31, 2024
@dosubot dosubot bot added the bug Something isn't working label Oct 31, 2024
@CaioAugustoo CaioAugustoo changed the title fix: look up to "approvals_left" instead of "approvals_before_merge" when checking if pull is mergeable fix: use "approvals_left" instead of "approvals_before_merge" when checking if pull is mergeable Oct 31, 2024
@jamengual jamengual added the waiting-on-review Waiting for a review from a maintainer label Oct 31, 2024
@X-Guardian
Copy link
Contributor

Hi @CaioAugustoo, thanks for this. Some of the current GitLab tests are failing after your change. Can you take a look at these? New tests are also needed to cover this new code.

@X-Guardian X-Guardian added needs tests Change requires tests and removed waiting-on-review Waiting for a review from a maintainer labels Nov 5, 2024
@X-Guardian X-Guardian changed the title fix: use "approvals_left" instead of "approvals_before_merge" when checking if pull is mergeable fix: GitLab - use "approvals_left" instead of "approvals_before_merge" when checking if pull is mergeable Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go Pull requests that update Go code needs tests Change requires tests provider/gitlab
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants