Python-Gitlab Unotect Master

发布于 2025-01-24 16:57:21 字数 243 浏览 2 评论 0原文

在创建项目并将用户添加为开发人员之后,我们一直在使用Python-GitLab的先前版本中,我们一直在使用:

# Unprotect master
branch = project.branches.get('master')
branch.unprotect()

我们希望允许开发人员访问主人。

版本3.2.0中不再可用,任何人都可以指导我如何使用新版本来实现相同的结果,

谢谢

In the previous version of Python-GitLab after creating the project and adding a user as a developer, we have been using:

# Unprotect master
branch = project.branches.get('master')
branch.unprotect()

as we wish to allow developer access to the master.

unprotect is no longer available in version 3.2.0 can anyone guide me on how to achieve the same result using the new version

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无边思念无边月 2025-01-31 16:57:21

您需要使用“ nofollow noreferrer”>受保护的分支a href =“ https://python-gitlab.readthedocs.io/en/stable/gl_objects/protection_branches.html” rel =“ nofollow noreferrer”> python-gitlab docs

protected_branch = project.protectedbranches.get("master")
protected_branch.delete()

# or simply
project.protectedbranches.delete("master")

注意:在这种情况下,delete()方法只需取消保护,它不会删除分支。

要重新保护它,您可以再次创建它。您还可以直接控制访问级别:

protected_branch = project.protectedbranches.create({
    'name': 'master',
    'merge_access_level': gitlab.const.DEVELOPER_ACCESS,
    'push_access_level': gitlab.const.MAINTAINER_ACCESS
})

You need to use the Protected Branches API (python-gitlab docs) for this.

protected_branch = project.protectedbranches.get("master")
protected_branch.delete()

# or simply
project.protectedbranches.delete("master")

Note: the delete() method in this case simply unprotects it, it does not delete the branch.

To re-protect it, you can then create it again. You can also control access levels directly:

protected_branch = project.protectedbranches.create({
    'name': 'master',
    'merge_access_level': gitlab.const.DEVELOPER_ACCESS,
    'push_access_level': gitlab.const.MAINTAINER_ACCESS
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文