build: add script to find commits suitable for cherry picking
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
1a2b7fef6c
commit
48a78f01a8
1 changed files with 44 additions and 0 deletions
44
build/find-cherry-pick-candidates.pl
Executable file
44
build/find-cherry-pick-candidates.pl
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
sub git {
|
||||||
|
my $res = undef;
|
||||||
|
|
||||||
|
if (open my $git, '-|', 'git', @_) {
|
||||||
|
{
|
||||||
|
local $/;
|
||||||
|
$res = readline $git;
|
||||||
|
}
|
||||||
|
|
||||||
|
chomp $res;
|
||||||
|
close $git;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $release_branch = git(qw(rev-parse --abbrev-ref HEAD));
|
||||||
|
my $default_branch = system(qw(git show-ref --verify --quiet refs/heads/main)) ? 'master' : 'main';
|
||||||
|
|
||||||
|
if ($release_branch eq $default_branch) {
|
||||||
|
printf STDERR "Please execute from a non-default branch\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
open my $cherry, '-|', 'git', 'cherry', '-v', $release_branch, $default_branch;
|
||||||
|
|
||||||
|
while (defined(my $line = readline $cherry)) {
|
||||||
|
my ($id, $subject) = $line =~ m!^\+ ([a-f0-9]+) (.*)$!;
|
||||||
|
next unless $id;
|
||||||
|
|
||||||
|
my $found = git('log', '-1', '-E', "--grep=(backported|cherry picked) from commit $id");
|
||||||
|
next if $found;
|
||||||
|
|
||||||
|
my @files = split /\n/, git('show', '--pretty=format:', '--name-only', $id);
|
||||||
|
next unless grep { !/\.pot?$/ } @files;
|
||||||
|
|
||||||
|
print "$id $subject\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
close $cherry;
|
Loading…
Reference in a new issue