Last active
September 10, 2015 04:56
-
-
Save MacoTasu/31839d90b5ae9301193c to your computer and use it in GitHub Desktop.
remote branch remove script
This file contains hidden or 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
use common::sense; | |
use Getopt::Long; | |
local $| = 1; | |
GetOptions(\my %opts, qw/ | |
prod | |
/); | |
my $prod = $opts{'prod'}; | |
sub trim { | |
my $val = shift; | |
$val =~ s/(origin\/)//g; | |
$val =~ s/^\s*(.*?)\s*$/$1/; | |
chomp($val); | |
return $val; | |
} | |
my @remote_branches = `git branch -r`; | |
my @branches = map { trim($_); } @remote_branches; | |
for my $branch (grep { $_ =~ /^jenkins\/*/ } @branches) { | |
if ($prod) { | |
`git push origin :$branch`; | |
} | |
else { | |
say $branch; | |
} | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment