Skip to content

Instantly share code, notes, and snippets.

@dagolden
Created March 27, 2013 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagolden/5258726 to your computer and use it in GitHub Desktop.
Save dagolden/5258726 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use v5.10;
use strict;
use warnings;
use Git::Wrapper;
use Time::Piece;
my ( $remote_repo, $remote_branch ) = @ARGV;
die "Usage: $0 <remote_repo> <remote_branch>"
unless $remote_repo;
$remote_branch //= 'master';
my $local_branch;
if ( $remote_repo =~ m{github\.com/([^/]+)/} ) {
$local_branch = "review/$1-$remote_branch";
}
else {
my $time = localtime->datetime;
$time =~ tr[:][-];
$local_branch = "review/$time";
}
my $git = Git::Wrapper->new(".");
$git->fetch( $remote_repo, $remote_branch );
$git->branch( $local_branch, 'FETCH_HEAD' );
say "Fetched $remote_repo $remote_branch -> $local_branch";
# vim: ts=4 sts=4 sw=4 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment