Sponsoring The Perl Toolchain Summit 2025: Help make this important event another success Learn more

use strict;
=head1 DESCRIPTION
Push current branch to writable github remotes.
=cut
sub run {
my $self = shift;
die unless( -e ".git/HEAD" );
open FH , "<" , ".git/HEAD";
my $ref = <FH>;
close FH;
chomp( $ref );
my ($branch) = ( $ref =~ m{ref:\s(\S+)} );
my @lines = split /\n/,qx{ git remote -v | grep '(fetch)'};
for my $line ( @lines ) {
my ( $remote , $uri , $type ) = ($line =~ m{^(\w+)\s+(\S+)\s+\((\w+)\)} );
_info "Updating from $remote ...";
qx{ git pull --rebase $remote $branch};
if( $uri =~ /^git\@github\.com/ ) {
_info "Pushing changes to $remote : $uri";
qx{ git push $remote $branch};
}
}
}
1;