Skip to content
\n

Any idea how to fix this?

","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"

I found a solution

\n
project = gl.projects.get(\"my-project\")\nmain_branch = project.protectedbranches.get(\"main\")\nproject.approvalrules.create(\n                {\n                    \"name\": rule_name,\n                    \"approvals_required\": 1,\n                    \"rule_type\": \"regular\",\n                    \"protected_branch_ids\": [main_branch_id.id],\n                    \"group_ids\": approver_group_ids,\n                }\n            )\n
","upvoteCount":1,"url":"https://github.com/python-gitlab/python-gitlab/discussions/3225#discussioncomment-13597753"}}}
Discussion options

You must be logged in to vote

I found a solution

project = gl.projects.get("my-project")
main_branch = project.protectedbranches.get("main")
project.approvalrules.create(
                {
                    "name": rule_name,
                    "approvals_required": 1,
                    "rule_type": "regular",
                    "protected_branch_ids": [main_branch_id.id],
                    "group_ids": approver_group_ids,
                }
            )

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by guerda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant