find-cherry-pick-candidates.pl 947 B

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