Skip to content

Instantly share code, notes, and snippets.

@Boettner-eric
Created March 1, 2023 19:12
Show Gist options
  • Save Boettner-eric/f8e617013146bc7c7db8f3b6807f4671 to your computer and use it in GitHub Desktop.
Save Boettner-eric/f8e617013146bc7c7db8f3b6807f4671 to your computer and use it in GitHub Desktop.
Create an MR from the command line
#!/usr/bin/env zsh
# - mr "title" "description"
# https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html
username='YOUR_USERNAME_HERE'
mrq='-o merge_request'
branch=$(git branch --show-current)
linearName=("${(@s/-/)branch}")
result=$(git push -u 2>&1 $mrq.create $mrq.target="master" $mrq.draft $mrq.title="[${linearName[1]:u}-${linearName[2]}] $1" $mrq.assign=$username)
parsed=$(echo $result | grep -Eo '(http|https)://[a-zA-Z0-9./?=_%:-]*' | tr -d '\n')
echo $result
if [[ $parsed = "" ]]; then
echo "No merge request created"
else
echo "Merge request created"
open -a $parsed;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment