get_maintainer: add ability to report Git Lab handle
With the GitLab mapping files from the previous commit, the get_manitainer.pl script is now able to report the gitlab handle for each maintainer/reviewer when displaying output. For example: $ ./scripts/get_maintainer.pl -f hw/scsi/lsi53c895a.c Paolo Bonzini <pbonzini@redhat.com> (supporter:SCSI, gitlab:@bonzini) Fam Zheng <fam@euphon.net> (reviewer:SCSI, gitlab:@famzheng) qemu-devel@nongnu.org (open list:All patches CC here) Reviewed-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Daniel P. Berrangé committed
Jun 22, 2026 at 11:59 UTC
84a6c5f94b3d3c445c55189d38aca22234054c10
1 file changed
+49
-4
scripts/get_maintainer.pl
+49
-4
@@ -365,6 +365,31 @@ sub read_mailmap {
365
close($mailmap_file);
366
}
367
368
+my %gitlabmap;
369
+
370
+read_gitlabmap(".gitlab-map-auto");
371
+read_gitlabmap(".gitlab-map-manual");
372
+
373
+sub read_gitlabmap {
374
+ my $mapfile = shift;
375
+ open MAP, "<$mapfile"
376
+ or die "cannot open $mapfile: $!";
377
+
378
+ while (<MAP>) {
379
+ next if /^#/;
380
+ next if /^\s*$/;
381
+
382
+ if (/^(\S+)\t(.*)$/) {
383
+ my $handle = $1;
384
+ my $realname = $2;
385
+
386
+ $gitlabmap{$realname} = $handle;
387
+ }
388
+ }
389
+
390
+ close MAP;
391
+}
392
+
393
## use the filenames on the command line or find the filenames in the patchfiles
394
395
my @files = ();
@@ -1068,6 +1093,18 @@ sub email_inuse {
1093
return 0;
1094
}
1095
1096
+sub gitlab_handle {
1097
+ my $name = shift;
1098
+
1099
+ $name =~ s/"//g;
1100
+
1101
+ my $gitlab_handle;
1102
+ if (exists $gitlabmap{$name}) {
1103
+ return $gitlabmap{$name};
1104
+ }
1105
+ return undef;
1106
+}
1107
+
1108
sub push_email_address {
1109
my ($line, $role) = @_;
1110
@@ -1077,10 +1114,14 @@ sub push_email_address {
1114
return 0;
1115
}
1116
1117
+ my $gitlab_handle = gitlab_handle($name);
1118
+
1119
if (!$email_remove_duplicates) {
1081
- push(@email_to, [format_email($name, $address, $email_usename), $role]);
1120
+ push(@email_to, [format_email($name, $address, $email_usename),
1121
+ $role, $gitlab_handle]);
1122
} elsif (!email_inuse($name, $address)) {
1083
- push(@email_to, [format_email($name, $address, $email_usename), $role]);
1123
+ push(@email_to, [format_email($name, $address, $email_usename),
1124
+ $role, $gitlab_handle]);
1125
$email_hash_name{lc($name)}++ if ($name ne "");
1126
$email_hash_address{lc($address)}++;
1127
}
@@ -2026,10 +2067,14 @@ sub merge_email {
2067
my %saw;
2068
2069
for (@_) {
2029
- my ($address, $role) = @$_;
2070
+ my ($address, $role, $gitlab_handle) = @$_;
2071
if (!$saw{$address}) {
2072
if ($output_roles) {
2032
- push(@lines, "$address ($role)");
2073
+ if (defined $gitlab_handle) {
2074
+ push(@lines, "$address ($role, gitlab:\@$gitlab_handle)");
2075
+ } else {
2076
+ push(@lines, "$address ($role)");
2077
+ }
2078
} else {
2079
push(@lines, $address);
2080
}