Skip to content

Instantly share code, notes, and snippets.

@officialcjunior
Last active May 31, 2020 13:48
Show Gist options
  • Save officialcjunior/68483708a1e325a11a61468daf67dec7 to your computer and use it in GitHub Desktop.
Save officialcjunior/68483708a1e325a11a61468daf67dec7 to your computer and use it in GitHub Desktop.
Create a Merge Reqest in Gitlab from the terminal.
import subprocess
import os
branch_name=input("Enter the target branch name, I mean, => target-repository:")
title=input("Enter the title or the Merge Request\n")
description=input("Enter description \n")
bool_origin=input("Is this branch already added in remote? (y/n) \n")
if bool_origin=='n':
origin = input("Input the branch name \n")
command='git push --set-upstream origin {forigin} \
-o merge_request.create \
-o merge_request.target="{f1}" \
-o merge_request.title="{f2}" \
-o merge_request.description="{f3}"'\
.format(forigin=origin, f1=branch_name,f2=title, f3=description)
else:
command='git push \
-o merge_request.create \
-o merge_request.target="{f1}" \
-o merge_request.title="{f2}" \
-o merge_request.description="{f3}"'\
.format(f1=branch_name,f2=title, f3=description)
bool_label=input("Do you want to add a label to this request? (y/n) \n")
if bool_label=='y':
label=input("Enter your label \n")
command += ' -o merge_request.label="{flabel}"'.format(flabel=label)
'''source_branch=input("Do you want to remove the source branch? (y/n)\n")
if (source_branch=='y' or source_branch=='Y'):
command += 'merge_request.remove_source_branch' '''
print(command)
subprocess.call(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment