What's cooking (2021/06 #06)
[git] / candidates
1 #!/usr/bin/perl
2 # Feed whats-cooking to this to find what to merge to 'master'
3
4 sub merged {
5         my ($topic, $base) = @_;
6         my $fh;
7         (open $fh, "-|", qw(git rev-list), "^$base", $topic)
8             or die "$!";
9         my $count = 0;
10         while (<$fh>) {
11                 $count++;
12         }
13         (close $fh)
14             or die "$! (after $count for $topic)";
15         return $count;
16 }
17
18 my ($topic, $topic_date, $last);
19 my (@candidate);
20
21 while (<>) {
22         if (/^\* ([a-z][a-z]\/[-a-zA-Z0-9_]+) \(([-0-9]{10})\) \d+ commit/) {
23                 $topic = $last = $1;
24                 $topic_date = $2;
25                 next;
26         }
27         if (defined $topic) {
28                 if (/^  \(merged to 'next' on ([-0-9]{10}) at/) {
29                         push @candidate, [$topic, $1, $topic_date, ""];
30                         next;
31                 }
32                 $topic = undef;
33                 $topic_date = undef;
34         }
35         if (defined $last && @candidate && $candidate[-1][0] eq $last) {
36                 if (/Will merge to 'master'/i) {
37                         $candidate[-1][3] = "*";
38                 }
39         }
40 }
41
42 for $topic (sort { ($a->[1] cmp $b->[1]) || ($a->[2] cmp $b->[2]) } @candidate) {
43         my $count = merged($topic->[0], 'master');
44         if ($count) {
45                 print "$topic->[1] $topic->[2] ($count) $topic->[3]$topic->[0]\n";
46         }
47 }