diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2016-07-23 21:02:30 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-07-23 21:02:30 -0700 |
commit | 3a511369d621a92b7a890d755be9875a27a27a52 (patch) | |
tree | 4fa61c086a5503598980dd7f231da6c66aa8140b /bin/git-push-all | |
parent | 6395195a796c436b6f03fe875e15b035043b5f39 (diff) | |
download | dotfiles-3a511369d621a92b7a890d755be9875a27a27a52.tar.gz |
git-push-all avoids creating branches
Diffstat (limited to 'bin/git-push-all')
-rwxr-xr-x | bin/git-push-all | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/git-push-all b/bin/git-push-all index b8f3734e..cfd30cb4 100755 --- a/bin/git-push-all +++ b/bin/git-push-all @@ -42,20 +42,21 @@ use strict; use warnings; +no warnings "experimental::smartmatch"; use Git::Wrapper; use Config::GitLike; -use List::MoreUtils qw{ uniq }; +use List::MoreUtils qw{ uniq apply }; my $git = Git::Wrapper->new("."); my $config = Config::GitLike->new( confname => 'config' ); $config->load_file('.git/config'); -my @branches = $git->branch; +my @branches = apply { s/[ \*]//g } $git->branch; +my @allBranches = apply { s/[ \*]//g } $git->branch({ all => 1 }); my $pushDefault = $config->get( key => "remote.pushDefault" ); foreach my $branch ( @branches ) { - $branch =~ s/[ \*]//g; my $pushRemote = $config->get( key => "branch.$branch.pushRemote" ); my $tracking = $config->get( key => "branch.$branch.remote" ); @@ -63,11 +64,14 @@ foreach my $branch ( @branches ) { print ">> pushing $branch to $pushRemote (its pushRemote)\n"; system "git push --follow-tags $pushRemote $branch"; exit 1 if ( $? != 0 ); - } elsif ( defined $pushDefault ) { + # don't push unless it already exists on the remote: this script + # avoids creating branches + } elsif ( defined $pushDefault + && "remotes/$pushDefault/$branch" ~~ @allBranches ) { print ">> pushing $branch to $pushDefault (the remote.pushDefault)\n"; system "git push --follow-tags $pushDefault $branch"; exit 1 if ( $? != 0 ); - } elsif ( defined "$tracking" ) { + } elsif ( !defined $pushDefault && defined $tracking ) { print ">> pushing $branch to $tracking (probably to its tracking branch)\n"; system "git push --follow-tags $tracking $branch"; exit 1 if ( $? != 0 ); |