Translated using Weblate (Russian)
[project/luci.git] / build / find-cherry-pick-candidates.pl
1 #!/usr/bin/env perl
2
3 use strict;
4
5 sub git {
6 my $res = undef;
7
8 if (open my $git, '-|', 'git', @_) {
9 {
10 local $/;
11 $res = readline $git;
12 }
13
14 chomp $res;
15 close $git;
16 }
17
18 return $res;
19 }
20
21 my $release_branch = git(qw(rev-parse --abbrev-ref HEAD));
22 my $default_branch = system(qw(git show-ref --verify --quiet refs/heads/main)) ? 'master' : 'main';
23
24 if ($release_branch eq $default_branch) {
25 printf STDERR "Please execute from a non-default branch\n";
26 exit 1;
27 }
28
29 open my $cherry, '-|', 'git', 'cherry', '-v', $release_branch, $default_branch;
30
31 while (defined(my $line = readline $cherry)) {
32 my ($id, $subject) = $line =~ m!^\+ ([a-f0-9]+) (.*)$!;
33 next unless $id;
34
35 my $found = git('log', '-1', '-E', "--grep=(backported|cherry picked) from commit $id");
36 next if $found;
37
38 my @files = split /\n/, git('show', '--pretty=format:', '--name-only', $id);
39 next unless grep { !/\.pot?$/ } @files;
40
41 print "$id $subject\n";
42 }
43
44 close $cherry;