summaryrefslogtreecommitdiff
path: root/bin/git-mr
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-02-18 16:24:27 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-02-18 16:24:50 -0700
commitded2b654acd54493f306a8a8f7c7f886ebc05ab8 (patch)
treeafcbf32b5d619a5c9a11bbd6c6f1e07f74ab9908 /bin/git-mr
parent4b72afe0fa4ba00b123e1cc66ff401cb04898954 (diff)
downloaddotfiles-ded2b654acd54493f306a8a8f7c7f886ebc05ab8.tar.gz
more flexible git-mr
Diffstat (limited to 'bin/git-mr')
-rwxr-xr-xbin/git-mr20
1 files changed, 15 insertions, 5 deletions
diff --git a/bin/git-mr b/bin/git-mr
index a71f50eb..bb53d7b2 100755
--- a/bin/git-mr
+++ b/bin/git-mr
@@ -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";