diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-02-18 16:24:27 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-02-18 16:24:50 -0700 |
commit | ded2b654acd54493f306a8a8f7c7f886ebc05ab8 (patch) | |
tree | afcbf32b5d619a5c9a11bbd6c6f1e07f74ab9908 /bin/git-mr | |
parent | 4b72afe0fa4ba00b123e1cc66ff401cb04898954 (diff) | |
download | dotfiles-ded2b654acd54493f306a8a8f7c7f886ebc05ab8.tar.gz |
more flexible git-mr
Diffstat (limited to 'bin/git-mr')
-rwxr-xr-x | bin/git-mr | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -1,10 +1,20 @@ #!/usr/bin/perl -use 5.028; use strict; use warnings; -die "usage: git mr REMOTE_NAME MERGE_REQUEST_ID BRANCH_NAME\n" - unless @ARGV == 3; -system "git fetch $ARGV[0] merge-requests/$ARGV[1]/head"; -system "git checkout -b mr/$ARGV[2] FETCH_HEAD"; +my ($remote, $id, $branch); +if (@ARGV == 1 and $ARGV[0] =~ /^[0-9]+$/) { + $remote = "origin"; + $id = $branch = shift @ARGV; +} elsif (@ARGV == 2) { + $remote = shift @ARGV; + $id = $branch = shift @ARGV; +} elsif (@ARGV == 3) { + ($remote, $id, $branch) = @ARGV; +} else { + die "usage: git mr [REMOTE_NAME] MERGE_REQUEST_ID [BRANCH_NAME]\n"; +} + +system "git fetch $remote merge-requests/$id/head"; +system "git checkout -b mr/$branch FETCH_HEAD"; |