author_requires 'Test::Pod::Coverage' => '1.04';
test_requires 'Test::More' => '0.88';
+test_requires 'Test::utf8' => '0.02';
resources bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Gitalist';
resources repository => 'git://git.shadowcat.co.uk/catagits/Gitalist.git';
use Moose::Autobox;
use List::MoreUtils qw/any zip/;
use DateTime;
+ use Encode qw/decode/;
+ use I18N::Langinfo qw/langinfo CODESET/;
use Gitalist::Git::Object::Blob;
use Gitalist::Git::Object::Tree;
use Gitalist::Git::Object::Commit;
}
method _build_owner {
- my ($gecos, $name) = (getpwuid $self->path->stat->uid)[6,0];
+ my ($gecos, $name) = map { decode(langinfo(CODESET), $_) } (getpwuid $self->path->stat->uid)[6,0];
$gecos =~ s/,+$//;
return length($gecos) ? $gecos : $name;
}
use FindBin qw/$Bin/;
use Test::More qw/no_plan/;
use Test::Exception;
+use Test::utf8;
+use Encode qw/decode_utf8/;
use Data::Dumper;
+BEGIN {
+ # Mocking to allow testing regardless of the user's locale
+ require I18N::Langinfo;
+ no warnings 'redefine';
+ *I18N::Langinfo::langinfo = sub($) {
+ return "UTF-8" if $_[0] == I18N::Langinfo::CODESET();
+ };
+ *CORE::GLOBAL::getpwuid = sub {
+ wantarray
+ ? ("test", "x", "1000", "1000", "", "", "T\x{c3}\x{a9}st", "/home/test", "/bin/bash")
+ : "test";
+ };
+}
+
BEGIN { use_ok 'Gitalist::Git::Project' }
dies_ok {
isa_ok($tree[0], 'Gitalist::Git::Object', 'tree element 0');
}
+my $owner = $proj->owner;
+is_flagged_utf8($owner, "Owner name is flagged as utf8");
+is_sane_utf8($owner, "Owner name is not double-encoded");
+is($owner, decode_utf8("T\x{c3}\x{a9}st"), "Owner name is correct");