aboutsummaryrefslogtreecommitdiff
path: root/hack/markdown-preprocess-review
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2022-08-16 09:36:02 -0600
committerEd Santiago <santiago@redhat.com>2022-08-22 05:52:20 -0600
commita0560eefaa1a5777ac910ec26af7a690a4b1f653 (patch)
treee80c07727b93c514a93a98425b82d9a694c7435a /hack/markdown-preprocess-review
parent351028b1ac87851fc084b8b5e09eb80660e6bb5a (diff)
downloadpodman-a0560eefaa1a5777ac910ec26af7a690a4b1f653.tar.gz
podman-a0560eefaa1a5777ac910ec26af7a690a4b1f653.tar.bz2
podman-a0560eefaa1a5777ac910ec26af7a690a4b1f653.zip
Man pages: refactor common options: cert-dir
...and, tweak markdown-process-review so it can detect and remove identical files, making review easier. Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'hack/markdown-preprocess-review')
-rwxr-xr-xhack/markdown-preprocess-review56
1 files changed, 54 insertions, 2 deletions
diff --git a/hack/markdown-preprocess-review b/hack/markdown-preprocess-review
index a487265ad..a3e237fb6 100755
--- a/hack/markdown-preprocess-review
+++ b/hack/markdown-preprocess-review
@@ -114,8 +114,60 @@ for my $i (0..$#all_opts) {
next if $ans =~ /^n/i;
exit 0 if $ans =~ /^q/i;
- system("diffuse", "-w", glob("*")) == 0
- or die "Diffuse failed\n";
+ # Try to cull the files (remove identical ones)
+ my @files = glob("*");
+ my $winner = pop @files;
+
+ for my $f (@files) {
+ system('cmp', '-s', $f, $winner);
+ if ($? == 0) {
+ print "[ $f is the one we went with; removing from list ]\n";
+ unlink $f;
+ next;
+ }
+
+ system('wdiff', '-1', '-2', '-3', $f, $winner);
+ if ($? == 0) {
+ print "[ $f is whitespace-identical with what we went with ]\n";
+ unlink $f;
+ next;
+ }
+ }
+
+ # Recompute @files, in case some were deleted above
+ @files = glob("*"); pop @files;
+
+ for (my $i=0; $i < $#files; $i++) {
+ my $f1 = $files[$i];
+ next unless -e $f1;
+
+ for (my $j=$i+1; $j <= $#files; $j++) {
+ my $f2 = $files[$j];
+ next unless -e $f2;
+
+ system('wdiff', '-1', '-2', '-3', $f1, $f2);
+ if ($? == 0) {
+ print "[ $f2 : removing, it =~ $f1 ]\n";
+ unlink $f2;
+ }
+ }
+ }
+
+ # Recompute @files, in case some were deleted above
+ @files = glob("*");
+
+ # diffuse works great for 3-4 files, passable for 5, not at all for >5
+ if (@files <= 5) {
+ system("diffuse", "-w", @files) == 0
+ or die "Diffuse failed\n";
+ }
+ else {
+ # Too many files. Go by threes.
+ my $winner = pop @files;
+ for (my $i=0; $i < @files; $i += 3) {
+ system("diffuse", "-w", @files[$i..$i+2], $winner);
+ }
+ }
}