diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2016-06-26 21:57:05 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-06-26 21:57:05 +0900 |
commit | f1309910838ffb7bad60fee9958e936b0e30fc09 (patch) | |
tree | 19a3d162061151bd0d83585b8849818728359871 /bin/git-push-all | |
parent | c49292fcfb71562a1969f9cdfe4aaebb9a461296 (diff) | |
download | dotfiles-f1309910838ffb7bad60fee9958e936b0e30fc09.tar.gz |
fill out git-push-all
Diffstat (limited to 'bin/git-push-all')
-rwxr-xr-x | bin/git-push-all | 37 |
1 files changed, 25 insertions, 12 deletions
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" ); + } +} |