How to create a GitLab merge request via command line

后端 未结 9 1115
清酒与你
清酒与你 2020-12-13 23:49

We are working on integrating GitLab (enterprise edition) in our tooling, but one thing that is still on our wishlist is to create a merge request in GitLab via a command li

相关标签:
9条回答
  • 2020-12-14 00:28

    In our build script we just pop up the browser with the correct URL and let the developer write his comments in the form hit save to create the merge request. You get this url with the correct parameters by creating a merge request manually and copying the url of the form.

    #!/bin/bash
    set -e
    set -o pipefail
    
    BRANCH=${2}
    
    ....
    
    git push -f origin-gitlab $BRANCH
    open "https://gitlab.com/**username**/**project-name**/merge_requests/new?merge_request%5Bsource_branch%5D=$BRANCH&merge_request%5Bsource_project_id%5D=99999&merge_request%5Btarget_branch%5D=master&merge_request%5Btarget_project_id%5D=99999"
    
    0 讨论(0)
  • 2020-12-14 00:29

    It's not natively supported, but it's not hard to throw together. The gitlab API has support for opening MR: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/merge_requests.md#create-mr

    0 讨论(0)
  • 2020-12-14 00:34

    As of GitLab 11.10, if you're using git 2.10 or newer, you can automatically create a merge request from the command line like this:

    git push -o merge_request.create
    

    More information can be found in the docs.

    0 讨论(0)
提交回复
热议问题