summaryrefslogtreecommitdiff
path: root/bin/git-mr
blob: 314a7e64d3aa281668cffde4863062bb1372c96e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env perl

use strict;
use warnings;

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";