]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cook.sh: move New Topics section to the beginning
authorJunio C Hamano <gitster@pobox.com>
Fri, 28 Aug 2009 07:42:57 +0000 (00:42 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Aug 2009 07:42:57 +0000 (00:42 -0700)
cook.sh

diff --git a/cook.sh b/cook.sh
index 8cba79ca4d28bb367086cb9094d02277affb3113..ff7c134068ebb0384aeb852b8f274cfe93a4881d 100755 (executable)
--- a/cook.sh
+++ b/cook.sh
@@ -287,18 +287,19 @@ perl -w -e '
                        $last_empty = 0;
                        if (!exists $branch{$branch}) {
                                push @branch, [$branch, $section];
-                               $branch{$branch} = (scalar @branch) - 1;
+                               $branch{$branch} = 1;
                        }
                        push @{$section{$section}}, $branch;
                }
                if (defined $branch) {
-                       if ($last_empty) {
-                               $_ = "\n$_";
-                       }
+                       my $was_last_empty = $last_empty;
                        $last_empty = 0;
                        if (!exists $description{$branch}) {
                                $description{$branch} = [];
                        }
+                       if ($was_last_empty) {
+                               push @{$description{$branch}}, "\n";
+                       }
                        push @{$description{$branch}}, $_;
                }
        }
@@ -309,12 +310,13 @@ perl -w -e '
                        my ($branch, $oldserial) = /^(\S*) (\d+)$/;
                        next if (exists $branch{$branch});
                        if (!exists $section{$section}) {
-                               push @section, $section;
+                               # Have it at the beginning
+                               unshift @section, $section;
                                $section{$section} = [];
                        }
                        push @{$section{$section}}, $branch;
                        push @branch, [$branch, $section];
-                       $branch{$branch} = (scalar @branch) - 1;
+                       $branch{$branch} = 1;
                        if (!exists $description{$branch}) {
                                $description{$branch} = [];
                        }
@@ -327,6 +329,16 @@ perl -w -e '
                close I;
        }
 
+       while (0 <= @{$description{$blurb}}) {
+               my $last = pop @{$description{$blurb}};
+               if ($last =~ /^$/ || $last =~ /^-{20,}$/) {
+                       next;
+               } else {
+                       push @{$description{$blurb}}, $last;
+                       last;
+               }
+       }
+
        open O, ">$tmp.template.blurb";
        for (@{$description{$blurb}}) {
                print O $_;
@@ -334,15 +346,16 @@ perl -w -e '
        close O;
 
        open TOC, ">$tmp.template.toc";
+       $serial = 1;
        for my $section (@section) {
                for my $branch (@{$section{$section}}) {
-                       my $serial = $branch{$branch};
                        print TOC "$branch $serial $section\n";
                        open O, ">$tmp.template.$serial";
                        for (@{$description{$branch}}) {
                                print O $_;
                        }
                        close O;
+                       $serial++;
                }
        }
 ' <"$template" "$tmp" "$incremental"
@@ -360,13 +373,14 @@ fi
 
 if test -s "$tmp.template.blurb"
 then
-       sed -e '/^---------------*/q' <"$tmp.output.blurb"
-       sed -e '1,/^---------------*/d' <"$tmp.template.blurb"
+       sed -e '/^---------------*$/q' <"$tmp.output.blurb"
+       sed -e '1,/^---------------*$/d' <"$tmp.template.blurb"
 else
        cat "$tmp.output.blurb"
-fi | sed -e '$d'
+fi
 
-current='--------------------------------------------------
+current='
+--------------------------------------------------
 [Graduated to "master"]
 '
 while read branch oldserial section
@@ -395,7 +409,8 @@ do
        if test "$current" != "$section"
        then
                current=$section
-               echo "--------------------------------------------------
+               echo "
+--------------------------------------------------
 [$section]
 "
        else