Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
remote branch remove script
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
You can’t perform that action at this time.