diff options
author | Eric Wong <e@80x24.org> | 2021-04-05 20:38:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-04-07 07:14:33 +0000 |
commit | 86c2ebf085cc9897bafcb95b82890f2645f515e5 (patch) | |
tree | 25122531ea8745faa1fc79bf801975be94115638 | |
parent | 64e5b12bca9148e74c4dca5f090decc21e12b879 (diff) | |
download | public-inbox-86c2ebf085cc9897bafcb95b82890f2645f515e5.tar.gz |
It's nicer in case a user transfers lei/store across machines and wants a way to track when/where they imported something.
-rw-r--r-- | lib/PublicInbox/LeiStore.pm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm index 094e1555..f8371abf 100644 --- a/lib/PublicInbox/LeiStore.pm +++ b/lib/PublicInbox/LeiStore.pm @@ -63,8 +63,16 @@ sub git_ident ($) { my $rdr = {}; open $rdr->{2}, '>', '/dev/null' or die "open /dev/null: $!"; chomp(my $i = $git->qx([qw(var GIT_COMMITTER_IDENT)], undef, $rdr)); - $i =~ /\A(.+) <([^>]+)> [0-9]+ [-\+]?[0-9]+$/ ? ($1, $2) : - ('lei user', 'x@example.com') + $i =~ /\A(.+) <([^>]+)> [0-9]+ [-\+]?[0-9]+$/ and return ($1, $2); + my ($user, undef, undef, undef, undef, undef, $gecos) = getpwuid($<); + ($user) = (($user // $ENV{USER} // '') =~ /([\w\-\.\+]+)/); + $user //= 'lei-user'; + ($gecos) = (($gecos // '') =~ /([\w\-\.\+ \t]+)/); + $gecos //= 'lei user'; + require Sys::Hostname; + my ($host) = (Sys::Hostname::hostname() =~ /([\w\-\.]+)/); + $host //= 'localhost'; + ($gecos, "$user\@$host") } sub importer { |