Skip to content

gitlab.projects.create from template creates project with unprotected main branch #3038

Answered by raedma
raedma asked this question in Q&A
Discussion options

You must be logged in to vote

As I have never used a template before, are you sure that using a template means it will create a protected branch?

Well, from my understanding the created project should be a quasi-copy of the template source. Also, I would expect any newly created project to have a protected main branch.

As a workaround you can protect the branch after creating the project: https://python-gitlab.readthedocs.io/en/stable/gl_objects/protected_branches.html#examples

Thanks, I saw that already. Re-tried it and now I can protected the main branch after project creation with

mainbranch = project.protectedbranches.create({
			'name': project.default_branch,
			'merge_access_level': gitlab.const.AccessLevel…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@JohnVillalovos
Comment options

@raedma
Comment options

@nejch
Comment options

Answer selected by JohnVillalovos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #3037 on November 14, 2024 16:18.