Meta/cook: teach 'source' heuristics for GGG topics

Junio C Hamano committed Jan 24, 2022 at 10:34 UTC 2bee5b8174dc82772256c3ea2bc44855f77fd5e9
1 file changed +32 -7
cook
+32 -7
@@ -127,6 +127,7 @@ sub get_source {
127 my ($branch) = @_;
128 my @id = ();
129 my %msgs = ();
130 + my @msgs = ();
131 my %source = ();
132 my %skip_me = ();
133
@@ -137,29 +138,53 @@ sub get_source {
138 if (s/^message-id:\s*<(.*)>\s*$/$1/i) {
139 my $msg = $_;
140 $msgs{$msg} = [get_message_parent($msg)];
140 - if (!%source) {
141 - $source{$msg} = $msg;
142 - }
141 + push @msgs, $msg;
142 }
143 }
144 close($fh);
145
146 # Collect parent messages that are not in the series,
147 # as they are likely to be the cover letters.
149 - for my $msg (keys %msgs) {
148 + for my $msg (@msgs) {
149 for my $parent (@{$msgs{$msg}}) {
150 if (!exists $msgs{$parent}) {
152 - $source{$parent} = 1;
151 + $source{$parent}++;
152 }
153 }
154 }
155
156 + reduce_sources(\@msgs, \%msgs, \%source);
157 +
158 map {
159 " source: <$_>";
160 }
161 (keys %source);
162 }
163
164 +sub reduce_sources {
165 + # Message-source specific hack
166 + my ($msgs_array, $msgs_map, $src_map) = @_;
167 +
168 + # messages without parent, or a singleton patch
169 + if ((! %$src_map && @{$msgs_array}) || (@{$msgs_array} == 1)) {
170 + %{$src_map} = ($msgs_array->[0] => 1);
171 + return;
172 + }
173 +
174 + # Is it from GGG?
175 + my @ggg_source = ();
176 + for my $msg (keys %$src_map) {
177 + if ($msg =~ /^pull\.[^@]*\.gitgitgadget\@/) {
178 + push @ggg_source, $msg;
179 + }
180 + }
181 + if (@ggg_source == 1) {
182 + %{$src_map} = ($ggg_source[0] => 1);
183 + return;
184 + }
185 +
186 +}
187 +
188 =head1
189 Inspect the current set of topics
190
@@ -676,7 +701,7 @@ sub tweak_willdo {
701
702 if (!defined $mergetomaster) {
703 my $master = `git describe $MASTER`;
679 - if ($master =~ /-rc\d+(-\d+-g[0-9a-f]+)?$/) {
704 + if ($master =~ /-rc(\d+)(-\d+-g[0-9a-f]+)?$/ && $1 != 0) {
705 $mergetomaster = "Will cook in 'next'.";
706 } else {
707 $mergetomaster = "Will merge to '$MASTER'.";
@@ -844,7 +869,7 @@ sub wildo_match {
869 # NEEDSWORK: unify with Reintegrate::annotate_merge
870 if (/^Will (?:\S+ ){0,2}(fast-track|hold|keep|merge|drop|discard|cook|kick|defer|eject|be re-?rolled|wait)[,. ]/ ||
871 /^Not urgent/ || /^Not ready/ || /^Waiting for / || /^Under discussion/ ||
847 - /^Can wait in / || /^Still / || /^Stuck / || /^On hold/ ||
872 + /^Can wait in / || /^Still / || /^Stuck / || /^On hold/ || /^Breaks / ||
873 /^Needs? / || /^Expecting / || /^May want to / || /^Under review/) {
874 return 1;
875 }