diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2016-12-22 15:16:54 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-12-22 15:16:54 +0000 |
commit | 583ebda22c89097101574a5b8e62529342dafdc9 (patch) | |
tree | 4a24deb8eafb81ae1b4d5bf83267d4960551cb62 /bin/git-push-all | |
parent | 3db25a34d0abfefe3240c8c5a41be7733b6158cb (diff) | |
download | dotfiles-583ebda22c89097101574a5b8e62529342dafdc9.tar.gz |
git push-all finds unpushed tags
Diffstat (limited to 'bin/git-push-all')
-rwxr-xr-x | bin/git-push-all | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/bin/git-push-all b/bin/git-push-all index 940d14ee..e0a35e7e 100755 --- a/bin/git-push-all +++ b/bin/git-push-all @@ -19,10 +19,10 @@ # Prerequisites: -# The Git::Wrapper, Config::GitLike, and List::MoreUtils perl -# libraries. On a Debian system, +# The Git::Wrapper, Array::Utils, Config::GitLike, and List::MoreUtils +# perl libraries. On a Debian system, # apt-get install libgit-wrapper-perl libconfig-gitlike-perl \ -# liblist-moreutils-perl +# liblist-moreutils-perl libarray-utils-perl # Description: @@ -44,6 +44,7 @@ use strict; use warnings; no warnings "experimental::smartmatch"; +use Array::Utils qw{ array_minus }; use Git::Wrapper; use Config::GitLike; use List::MoreUtils qw{ uniq apply }; @@ -80,7 +81,36 @@ foreach my $branch ( @branches ) { } foreach my $remote ( keys %pushes ) { + # TODO if $remote eq $pushDefault, consider s/follow-// below + # I almost certainly want all tags on that remote (e.g. an alioth repo) my @branches = @{ $pushes{$remote} }; system "git push --follow-tags $remote @branches"; exit 1 if ( $? != 0 ); } + +# Now find any tags that have not been pushed to any remote. +# --follow-tags should avoid this, but sometimes tags fall through the +# gaps. It will also catch unannotated tags, since --follow-tags +# ignores those, and I probably don't want them + +# TODO if this turns out to be slow, split out into a script run +# weekly as part of ~/bin/sysmaint + +my @tags = $git->tag; +my @remotes = $git->remote; +my @pushed_tags; + +foreach my $remote ( @remotes ) { + my @this_remote_tags = apply { s|\^\{\}$||; s|[a-f0-9]+\trefs/tags/|| } + $git->ls_remote( { tags => 1 }, $remote ); + push @pushed_tags, @this_remote_tags; +} + +@pushed_tags = uniq @pushed_tags; +my @unpushed_tags = array_minus ( @tags, @pushed_tags ); + +if ( scalar @unpushed_tags > 0 ) { + print "E: the following tags have not been pushed to any remote:\n"; + print join(", ", @unpushed_tags); + exit 1; +} |