Created
March 27, 2013 22:33
-
-
Save dagolden/5258726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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