python-gitlab 之更改 merge_method

Posted pengdonglin137

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python-gitlab 之更改 merge_method相关的知识,希望对你有一定的参考价值。

参考:

https://docs.gitlab.com/ee/api/projects.html

https://python-gitlab.readthedocs.io/en/stable/gl_objects/projects.html#

 

Project merge method

There are currently three options for merge_method to choose from:

  • merge: A merge commit is created for every merge, and merging is allowed as long as there are no conflicts.

  • rebase_merge: A merge commit is created for every merge, but merging is only allowed if fast-forward merge is possible. This way you could make sure that if this merge request would build, after merging to target branch it would also build.

  • ff: No merge commits are created and all merges are fast-forwarded, which means that merging is only allowed if the branch could be fast-forwarded.

 

技术图片

 

 

测试

#!/usr/bin/env python3

import gitlab
import sys
import os
import subprocess
import xml.dom.minidom
from xml.dom.minidom import parse

url = "http://192.168.1.100:12345"
token = DFnkTaxn9sk382onzEzw

if __name__ == __main__:

    gl = gitlab.Gitlab(url, private_token=token)
    print("Connect to gitlab url: " + url)

    project = gl.projects.get("thirdpart/spdk")
    print(project)
    print(project.merge_method)

    project.merge_method = merge
    project.save()
    print("======> set to ‘merge‘")
    project = gl.projects.get("thirdpart/spdk")
    print(project.merge_method)

    project.merge_method = ff
    project.save()
    print("======> set to ‘ff‘")
    project = gl.projects.get("thirdpart/spdk")
    print(project.merge_method)

    project.merge_method = rebase_merge
    project.save()
    print("======> set to ‘rebase_merge‘")
    project = gl.projects.get("thirdpart/spdk")
    print(project.merge_method)

    sys.exit(0)

 

Log

技术图片

 

完。

以上是关于python-gitlab 之更改 merge_method的主要内容,如果未能解决你的问题,请参考以下文章

python-gitlab库操作gitlab的API

python通过接口获取gitlab项目信息

如何从 Gitlab API 获取用户所有已加星标的项目

使用ms字VBA宏合并表中的单元格

curl的Python版本--输出

nginx优化之更改用户