From f1309910838ffb7bad60fee9958e936b0e30fc09 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 26 Jun 2016 21:57:05 +0900 Subject: fill out git-push-all --- bin/git-push-all | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'bin/git-push-all') diff --git a/bin/git-push-all b/bin/git-push-all index 0ddc339b..c9a10d57 100755 --- a/bin/git-push-all +++ b/bin/git-push-all @@ -19,8 +19,10 @@ # Prerequisites: -# The Git::Wrapper and Config::GitLike perl library. On a Debian system, -# apt-get install libgit-wrapper-perl libconfig-gitlike-perl +# The Git::Wrapper, Config::GitLike, and List::MoreUtils perl +# libraries. On a Debian system, +# apt-get install libgit-wrapper-perl libconfig-gitlike-perl \ +# liblist-moreutils-perl # Description: @@ -50,17 +52,28 @@ use warnings; use Git::Wrapper; use Config::GitLike; - -use Data::Dumper; +use List::MoreUtils qw{ uniq }; my $git = Git::Wrapper->new("."); -my $config = Config::GitLike->load_file(".git/config"); - -# $config->get_regexp( key => "branch.*pushRemote" ); +my $config = Config::GitLike->new( confname => 'config' ); +$config->load_file('.git/config'); -# my @remotes = $git->remote; -# foreach my $remote ( @remotes ) { -# unless ( $remote eq "dgit" ) { +my $pushRemotes = $config->get_regexp( key => "branch\..*\.pushRemote" ); +my @pushRemotes = uniq(values %$pushRemotes); +my $pushDefault = $config->get( key => "remote.pushDefault" ); +push @pushRemotes, $pushDefault if ( defined $pushDefault ); +my @remotes = $git->remote; -# } -# } +if ( defined $pushDefault ) { + # mode one: assume that there are read-only remotes + foreach my $remote ( @pushRemotes ) { + $git->push("--follow-tags", $remote, ":") + unless ( $remote eq "dgit" ); + } +} else { + # mode two: assume we can write to all remotes + foreach my $remote ( @remotes ) { + $git->push("--tags", $remote, ":") + unless ( $remote eq "dgit" ); + } +} -- cgit v1.2.3