cook.sh: move New Topics section to the beginning
Junio C Hamano committed
Aug 28, 2009 at 00:42 UTC
5c74ceb4ff618fb19be0f9561a884ff6cfbd1085
1 file changed
+27
-12
cook.sh
+27
-12
@@ -287,18 +287,19 @@ perl -w -e '
287
$last_empty = 0;
288
if (!exists $branch{$branch}) {
289
push @branch, [$branch, $section];
290
- $branch{$branch} = (scalar @branch) - 1;
290
+ $branch{$branch} = 1;
291
}
292
push @{$section{$section}}, $branch;
293
}
294
if (defined $branch) {
295
- if ($last_empty) {
296
- $_ = "\n$_";
297
- }
295
+ my $was_last_empty = $last_empty;
296
$last_empty = 0;
297
if (!exists $description{$branch}) {
298
$description{$branch} = [];
299
}
300
+ if ($was_last_empty) {
301
+ push @{$description{$branch}}, "\n";
302
+ }
303
push @{$description{$branch}}, $_;
304
}
305
}
@@ -309,12 +310,13 @@ perl -w -e '
310
my ($branch, $oldserial) = /^(\S*) (\d+)$/;
311
next if (exists $branch{$branch});
312
if (!exists $section{$section}) {
312
- push @section, $section;
313
+ # Have it at the beginning
314
+ unshift @section, $section;
315
$section{$section} = [];
316
}
317
push @{$section{$section}}, $branch;
318
push @branch, [$branch, $section];
317
- $branch{$branch} = (scalar @branch) - 1;
319
+ $branch{$branch} = 1;
320
if (!exists $description{$branch}) {
321
$description{$branch} = [];
322
}
@@ -327,6 +329,16 @@ perl -w -e '
329
close I;
330
}
331
332
+ while (0 <= @{$description{$blurb}}) {
333
+ my $last = pop @{$description{$blurb}};
334
+ if ($last =~ /^$/ || $last =~ /^-{20,}$/) {
335
+ next;
336
+ } else {
337
+ push @{$description{$blurb}}, $last;
338
+ last;
339
+ }
340
+ }
341
+
342
open O, ">$tmp.template.blurb";
343
for (@{$description{$blurb}}) {
344
print O $_;
@@ -334,15 +346,16 @@ perl -w -e '
346
close O;
347
348
open TOC, ">$tmp.template.toc";
349
+ $serial = 1;
350
for my $section (@section) {
351
for my $branch (@{$section{$section}}) {
339
- my $serial = $branch{$branch};
352
print TOC "$branch $serial $section\n";
353
open O, ">$tmp.template.$serial";
354
for (@{$description{$branch}}) {
355
print O $_;
356
}
357
close O;
358
+ $serial++;
359
}
360
}
361
' <"$template" "$tmp" "$incremental"
@@ -360,13 +373,14 @@ fi
373
374
if test -s "$tmp.template.blurb"
375
then
363
- sed -e '/^---------------*/q' <"$tmp.output.blurb"
364
- sed -e '1,/^---------------*/d' <"$tmp.template.blurb"
376
+ sed -e '/^---------------*$/q' <"$tmp.output.blurb"
377
+ sed -e '1,/^---------------*$/d' <"$tmp.template.blurb"
378
else
379
cat "$tmp.output.blurb"
367
-fi | sed -e '$d'
380
+fi
381
369
-current='--------------------------------------------------
382
+current='
383
+--------------------------------------------------
384
[Graduated to "master"]
385
'
386
while read branch oldserial section
@@ -395,7 +409,8 @@ do
409
if test "$current" != "$section"
410
then
411
current=$section
398
- echo "--------------------------------------------------
412
+ echo "
413
+--------------------------------------------------
414
[$section]
415
"
416
else