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

 

完。

转载于:https://www.cnblogs.com/pengdonglin137/p/10920772.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值