Daniel P. Berrangé <[email protected]> writes: > 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 <[email protected]> (supporter:SCSI, gitlab:@bonzini) > Fam Zheng <[email protected]> (reviewer:SCSI, gitlab:@famzheng) > [email protected] (open list:All patches CC here)
I suspect it gets tripped up by utf-8 stuff: ➜ ./scripts/get_maintainer.pl -f contrib/gitdm/aliases "Alex Bennée" <[email protected]> (odd fixer:GIT Data Mining C...) [email protected] (open list:All patches CC here) misses my tag. However I think this approach is much cleaner. The other option would be embedding @refs in the M: line: M: Alex Bennée <[email protected]> @stsquad and letting the script handle it. But I didn't want to hack on get_maintainer.pl which is why I started playing with a python version. However I need to add some features to it to reach usable parity with the perl script. > > Signed-off-by: Daniel P. Berrangé <[email protected]> > --- > scripts/get_maintainer.pl | 42 +++++++++++++++++++++++++++++++++++---- > 1 file changed, 38 insertions(+), 4 deletions(-) > > diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl > index 76be402e11..1f518b6792 100755 > --- a/scripts/get_maintainer.pl > +++ b/scripts/get_maintainer.pl > @@ -365,6 +365,31 @@ sub read_mailmap { > close($mailmap_file); > } > > +my %gitlabmap; > + > +read_gitlabmap(".gitlab-map-auto"); > +read_gitlabmap(".gitlab-map-manual"); > + > +sub read_gitlabmap { > + my $mapfile = shift; > + open MAP, "<$mapfile" > + or die "cannot open $mapfile: $!"; > + > + while (<MAP>) { > + next if /^#/; > + next if /^\s*$/; > + > + if (/^(\S+)\t(.*)$/) { > + my $handle = $1; > + my $realname = $2; > + > + $gitlabmap{$realname} = $handle; > + } > + } > + > + close MAP; > +} > + > ## use the filenames on the command line or find the filenames in the > patchfiles > > my @files = (); > @@ -1077,10 +1102,15 @@ sub push_email_address { > return 0; > } > > + my $gitlab_handle; > + if (exists $gitlabmap{$name}) { > + $gitlab_handle = $gitlabmap{$name}; > + } > + > if (!$email_remove_duplicates) { > - push(@email_to, [format_email($name, $address, $email_usename), $role]); > + push(@email_to, [format_email($name, $address, $email_usename), $role, > $gitlab_handle]); > } elsif (!email_inuse($name, $address)) { > - push(@email_to, [format_email($name, $address, $email_usename), $role]); > + push(@email_to, [format_email($name, $address, $email_usename), $role, > $gitlab_handle]); > $email_hash_name{lc($name)}++ if ($name ne ""); > $email_hash_address{lc($address)}++; > } > @@ -2026,10 +2056,14 @@ sub merge_email { > my %saw; > > for (@_) { > - my ($address, $role) = @$_; > + my ($address, $role, $gitlab_handle) = @$_; > if (!$saw{$address}) { > if ($output_roles) { > - push(@lines, "$address ($role)"); > + if (defined $gitlab_handle) { > + push(@lines, "$address ($role, gitlab:\@$gitlab_handle)"); > + } else { > + push(@lines, "$address ($role)"); > + } > } else { > push(@lines, $address); > } -- Alex Bennée Virtualisation Tech Lead @ Linaro
