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

feat: gitlab_project module - Allow to update project default branch #7158

Conversation

lgatellier
Copy link
Contributor

SUMMARY

This PR allow gitlab_project module to update a GitLab project's default branch.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

gitlab_project module

ADDITIONAL INFORMATION

Fixes #5995

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added WIP Work in progress feature This issue/PR relates to a feature request has_issue module module plugins plugin (any type) labels Aug 27, 2023
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-7 Automatically create a backport for the stable-7 branch breaking_change This PR contains a breaking change that MUST NOT be backported and removed backport-7 Automatically create a backport for the stable-7 branch labels Aug 28, 2023
@felixfontein
Copy link
Collaborator

You also need to update the documentation for default_branch.

The gitlab_project module always stated that default_branch is only using during creation. Some users might rely on that and be very surprised if it suddenly starts using that value to update. So this should be marked as a breaking change, and not backported to stable-7.

Out of curiosity, what happens if you provide a name that doesn't exist as a branch? Does the API rename the current default branch to the new name? Or will it simply create the new branch based on the current default branch? Or will it simply fail?

@lgatellier
Copy link
Contributor Author

lgatellier commented Sep 2, 2023

Thanks @felixfontein for your feedback. I updated the documentation.

It's clearly a breaking change, since the module will update a field it did not before this PR.

If the provided branch does not exist, the GitLab API will return an HTTP 400 error like that :

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed update project: 400: {'base': ["Could not change HEAD: branch 'nonexistingbranch' does not exist"]} "}

A branch rename (like git branch -m) is not possible with GitLab, you have to create the new branch, update project's default branch, and all branch protection rules.

@lgatellier lgatellier force-pushed the feat/gitlab-project-update-default-branch branch 2 times, most recently from f6b3b24 to 1e6e9d8 Compare September 2, 2023 13:39
@lgatellier lgatellier marked this pull request as ready for review September 2, 2023 13:41
@ansibullbot ansibullbot removed the WIP Work in progress label Sep 2, 2023
@lgatellier lgatellier force-pushed the feat/gitlab-project-update-default-branch branch 2 times, most recently from 7cab6a5 to a7d7e3e Compare September 2, 2023 13:46
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

I would extend the changelog fragment a bit to point out in which cases users could see unexpected breaking changes; besides that everything looks good!

@lgatellier lgatellier force-pushed the feat/gitlab-project-update-default-branch branch from ad6665c to d548441 Compare September 3, 2023 17:03
@lgatellier
Copy link
Contributor Author

@felixfontein I applied your suggestions, thanks !

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

LGTM! I will merge this in a few days if nobody objects.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Sep 6, 2023
@felixfontein felixfontein merged commit 6b17ac1 into ansible-collections:main Sep 6, 2023
145 checks passed
@felixfontein
Copy link
Collaborator

@lgatellier thanks for implementing this!

@lgatellier lgatellier deleted the feat/gitlab-project-update-default-branch branch September 6, 2023 17:12
etrombly pushed a commit to etrombly/community.general that referenced this pull request Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking_change This PR contains a breaking change that MUST NOT be backported feature This issue/PR relates to a feature request has_issue module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

community.general.gitlab_branch: add option default (branch)
3 participants