Meta/add-by: support --mine=<sig> to keep the trailer at the end
parent
bd930c8325
commit
ddb098fc28
27
add-by
27
add-by
|
@ -46,14 +46,19 @@ sub accumulate {
|
||||||
push @more, [@_];
|
push @more, [@_];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_more_bylines {
|
my $mine;
|
||||||
if (!defined $append) {
|
|
||||||
|
sub compute_bylines {
|
||||||
my %names = map { $_->[1] => 1 } @more;
|
my %names = map { $_->[1] => 1 } @more;
|
||||||
my %map = ();
|
my %map = ();
|
||||||
my @append;
|
my @append;
|
||||||
find_author(\%map, keys (%names));
|
find_author(\%map, keys (%names));
|
||||||
for (@more) {
|
for (@more) {
|
||||||
my ($tag, $name) = @$_;
|
my ($tag, $name) = @$_;
|
||||||
|
if ($tag eq 'mine') {
|
||||||
|
$mine = $map{$name};
|
||||||
|
next;
|
||||||
|
}
|
||||||
$tag = ucfirst($tag);
|
$tag = ucfirst($tag);
|
||||||
push @append, "$tag: $map{$name}";
|
push @append, "$tag: $map{$name}";
|
||||||
}
|
}
|
||||||
|
@ -62,6 +67,11 @@ sub add_more_bylines {
|
||||||
} else {
|
} else {
|
||||||
$append = "";
|
$append = "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub add_more_bylines {
|
||||||
|
if (!defined $append) {
|
||||||
|
compute_bylines();
|
||||||
}
|
}
|
||||||
print $append;
|
print $append;
|
||||||
}
|
}
|
||||||
|
@ -74,25 +84,36 @@ exit 1 unless (GetOptions("signed-off-by=s" => \&accumulate,
|
||||||
"tested-by=s" => \&accumulate,
|
"tested-by=s" => \&accumulate,
|
||||||
"helped-by=s" => \&accumulate,
|
"helped-by=s" => \&accumulate,
|
||||||
"check-only!" => \$check_only,
|
"check-only!" => \$check_only,
|
||||||
|
"mine=s" => \&accumulate,
|
||||||
"debug!" => \$debug,
|
"debug!" => \$debug,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
compute_bylines();
|
||||||
|
|
||||||
if ($check_only) {
|
if ($check_only) {
|
||||||
add_more_bylines();
|
add_more_bylines();
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $seen_mine = 0;
|
||||||
while (<>) {
|
while (<>) {
|
||||||
if ($state == parsing) {
|
if ($state == parsing) {
|
||||||
if (/^[-A-Za-z]+-by: /i || /^Cc: /i) {
|
if (/^[-A-Za-z]+-by: /i || /^Cc: /i) {
|
||||||
$state = waiting;
|
$state = waiting;
|
||||||
}
|
}
|
||||||
} elsif ($state == waiting) {
|
} elsif ($state == waiting) {
|
||||||
if (/^[-A-Za-z]+-by: /i || /^Cc: /i) {
|
if (defined $mine && /^Signed-off-by: \Q$mine\E/) {
|
||||||
|
$seen_mine = 1;
|
||||||
|
next;
|
||||||
|
} elsif (/^[-A-Za-z]+-by: /i || /^Cc: /i) {
|
||||||
$state = waiting;
|
$state = waiting;
|
||||||
} else {
|
} else {
|
||||||
add_more_bylines();
|
add_more_bylines();
|
||||||
|
if ($seen_mine) {
|
||||||
|
print "Signed-off-by: $mine\n";
|
||||||
|
}
|
||||||
$state = parsing;
|
$state = parsing;
|
||||||
|
$seen_mine = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print;
|
print;
|
||||||
|
|
Loading…
Reference in New Issue