]> Sergey Matveev's repositories - public-inbox.git/commitdiff
edit|purge: improve output on rewrites
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 10 Jun 2019 16:58:55 +0000 (16:58 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 10 Jun 2019 17:53:08 +0000 (17:53 +0000)
Fill in undef as "(unchanged)" when displaying commits
and prefix the epoch name.

lib/PublicInbox/AdminEdit.pm
script/public-inbox-edit
script/public-inbox-purge
t/purge.t

index b27c831b3ee30363795be25525dd5387d7e9fa85..169feba0dba9dbe8f3aa3778f4635e9a973118c6 100644 (file)
@@ -47,4 +47,21 @@ sub check_editable ($) {
        }
 }
 
+# takes the output of V2Writable::purge and V2Writable::replace
+# $rewrites = [ array commits keyed by epoch ]
+sub show_rewrites ($$$) {
+       my ($fh, $ibx, $rewrites) = @_;
+       print $fh "$ibx->{mainrepo}:";
+       if (scalar @$rewrites) {
+               my $epoch = -1;
+               my @out = map {;
+                       ++$epoch;
+                       "$epoch.git: ".(defined($_) ? $_ : '(unchanged)')
+               } @$rewrites;
+               print $fh join("\n\t", '', @out), "\n";
+       } else {
+               print $fh " NONE\n";
+       }
+}
+
 1;
index ff0351a389cca4243a28a64971ba3b8533438da4..7a534cc2b094bc5f796a34aec32ce76dbda0a48a 100755 (executable)
@@ -207,7 +207,7 @@ W: possible message boundary splitting error
 
                next unless $opt->{verbose};
                # should we consider this machine-parseable?
-               print "$ibx->{mainrepo}:\n\tNONE\n";
+               PublicInbox::AdminEdit::show_rewrites(\*STDOUT, $ibx, []);
                next;
        }
 
@@ -223,11 +223,6 @@ W: possible message boundary splitting error
                }
                next unless $opt->{verbose};
                # should we consider this machine-parseable?
-               print "$ibx->{mainrepo}:";
-               if (scalar @$commits) {
-                       print join("\n\t", '', @$commits), "\n";
-               } else {
-                       print "\tNONE\n";
-               }
+               PublicInbox::AdminEdit::show_rewrites(\*STDOUT, $ibx, $commits);
        }
 }
index 846557cab47b6d1c235222fbc0bf345c93e69269..0705d170eae8806f706c75e246cd7594b2b20f20 100755 (executable)
@@ -45,12 +45,7 @@ foreach my $ibx (@ibxs) {
        $v2w->done;
 
        if ($opt->{verbose}) { # should we consider this machine-parseable?
-               print "$ibx->{mainrepo}:";
-               if (scalar @$commits) {
-                       print join("\n\t", '', @$commits), "\n";
-               } else {
-                       print " NONE\n";
-               }
+               PublicInbox::AdminEdit::show_rewrites(\*STDOUT, $ibx, $commits);
        }
        $n_purged += scalar @$commits;
 }
index c1e0e9a023ab8e4b24d513ab7020591ac9ffa3a6..384f32a652bfce92eb917093cfbc5ba37002c9bc 100644 (file)
--- a/t/purge.t
+++ b/t/purge.t
@@ -57,7 +57,7 @@ is($? >> 8, 1, 'missed purge exits with 1');
 
 # a successful case:
 ok(IPC::Run::run([$purge, $mainrepo], \$raw, \$out, \$err), 'match OK');
-like($out, qr/^\t[a-f0-9]{40,}/m, 'removed commit noted');
+like($out, qr/\b[a-f0-9]{40,}/m, 'removed commit noted');
 
 # add (old) vger filter to config file
 print $cfg_fh <<EOF or die "print $!";
@@ -85,7 +85,7 @@ $out = $err = '';
 ok(chdir('/'), "chdir / OK for --all test");
 ok(IPC::Run::run([$purge, '--all'], \$pre_scrub, \$out, \$err),
        'scrub purge OK');
-like($out, qr/^\t[a-f0-9]{40,}/m, 'removed commit noted');
+like($out, qr/\b[a-f0-9]{40,}/m, 'removed commit noted');
 # diag "out: $out"; diag "err: $err";
 
 $out = $err = '';