--- cvs2cl.pl 2003-01-18 14:28:18.000000000 -0800 +++ cvs2cl.pl.new 2003-02-22 22:29:06.000000000 -0800 @@ -17,6 +17,7 @@ ## (C) 1999 Karl Fogel , under the GNU GPL. ## ## (Extensively hacked on by Melissa O'Neill .) +## (Gecos hacking by Robin Johnson .) ## ## cvs2cl.pl is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -38,6 +39,7 @@ use Text::Wrap; use Time::Local; use File::Basename; +use User::pwent; # The Plan: @@ -105,6 +107,12 @@ # Expand usernames to email addresses based on a map file? my $User_Map_File = ""; +# Grab user details via gecos +my $Gecos = 0; + +# User domain for gecos email addresses +my $Domain = ""; + # Output to a file or to stdout? my $Output_To_Stdout = 0; @@ -477,6 +485,22 @@ ($time, $author) = &parse_date_and_author ($_); if (defined ($usermap{$author}) and $usermap{$author}) { $author = $usermap{$author}; + } elsif($Domain ne "" or $Gecos == 1) { + my $email = $author; + if($Domain ne "") { + $email = $author."@".$Domain; + } + my $pw = getpwnam($author); + my $fullname; + my $office; + my $workphone; + my $homephone; + for (($fullname, $office, $workphone, $homephone) = split /\s*,\s*/, $pw->gecos) { + s/&/ucfirst(lc($pw->name))/ge; + } + if($fullname ne "") { + $author = $fullname . " <" . $email . ">"; + } } } else { @@ -1591,7 +1615,7 @@ else { $expansions{$username} = $expansion; } - } + } # fi ($User_Map_File) close (MAPFILE); } @@ -1652,6 +1676,13 @@ my $narg = shift (@ARGV) || die "$arg needs argument.\n"; $User_Map_File = $narg; } + elsif ($arg =~ /^-G|^--gecos$/) { + $Gecos = 1; + } + elsif ($arg =~ /^-D|^--domain$/) { + my $narg = shift (@ARGV) || die "$arg needs argument.\n"; + $Domain = $narg; + } elsif ($arg =~ /^-W$|^--window$/) { defined(my $narg = shift (@ARGV)) || die "$arg needs argument.\n"; $Max_Checkin_Duration = $narg; @@ -1866,6 +1897,8 @@ --fsf Use this if log data is in FSF ChangeLog style -W SECS, --window SECS Window of time within which log entries unify -U UFILE, --usermap UFILE Expand usernames to email addresses from UFILE + -D DOMAIN, --domain DOMAIN Domain to build email addresses from + -G, --gecos Get user information from GECOS data -R REGEXP, --regexp REGEXP Include only entries that match REGEXP -I REGEXP, --ignore REGEXP Ignore files whose names match REGEXP -C, --case-insensitive Any regexp matching is done case-insensitively