python-gitlab - 如何修改项目设置?
我正在编写一个 python 模块来在 gitlab 中创建项目,但我不知道如何更改默认项目设置,例如 remove_source_branch_after_merge
。
我尝试将参数传递给 projects.create()
调用,但它似乎被忽略。
project = gl.projects.create({'name': reponame, 'namespace_id': group_id, 'default_branch' : default_branch, 'remove_source_branch_after_merge' : False})
我设法通过手动 POST 到 /api/v4/projects/$ID?remove_source_branch_after_merge=false
来更改设置,但我不知道如何在 python-gitlab 中执行此操作。
如何创建具有自定义设置的项目,或在 python-gitlab 中创建项目后修改项目设置?
我正在使用 python-gitlab==1.7.0
I'm writing a python module to create projects in gitlab, but I can't figure out how to change the default project settings, like remove_source_branch_after_merge
.
I've tried passing the argument to the projects.create()
call, but it seems to be ignored.
project = gl.projects.create({'name': reponame, 'namespace_id': group_id, 'default_branch' : default_branch, 'remove_source_branch_after_merge' : False})
I managed to change the setting by manually POST'ing to /api/v4/projects/$ID?remove_source_branch_after_merge=false
but I can't figure out how to do this in python-gitlab.
How can I create a project with customized settings, or modify a project settings after its creation in python-gitlab
?
I'm using python-gitlab==1.7.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要回答您的问题,可以使用
save()
在创建对象后修改属性:但是,我认为您的初始创建调用应该工作,所以也许检查任何拼写错误。 1.7.0 已经很老了,我刚刚检查过它在 3.2.0 上是否有效。您还可以使用
gl.enable_debug()
获取详细输出并检查是否将正确的参数发送到 API。To answer your question, modifying attributes after an object has been created can be done with
save()
:However, I think your initial create call should work, so maybe check for any typos. 1.7.0 is quite old, and I just checked this works on 3.2.0. You can also use
gl.enable_debug()
to get verbose output and check that the right parameters are sent to the API.