use Moose::Autobox;
use List::MoreUtils qw/any zip/;
use DateTime;
- use Gitalist::Util qw(to_utf8);
use Gitalist::Git::Object::Blob;
use Gitalist::Git::Object::Tree;
use Gitalist::Git::Object::Commit;
$format = $formats->{$format};
my $name = $self->name;
$name =~ s,([^/])/*\.git$,$1,;
- my $filename = to_utf8($name);
+ my $filename = $name;
$filename .= "-$sha1.$format";
$name =~ s/\047/\047\\\047\047/g;
-
my @cmd = ('archive', "--format=$format", "--prefix=$name/", $sha1);
return ($filename, $self->run_cmd_fh(@cmd));
# TODO - support compressed archives
use FindBin;
binmode STDOUT, ':utf8';
-use Gitalist::Util qw(to_utf8);
-
BEGIN {
CGI->compile();
}
return @list && scalar(grep { $_->{'path'} eq $project } @list);
}
+# decode sequences of octets in utf8 into Perl's internal form,
+# which is utf-8 with utf8 flag set if needed. gitweb writes out
+# in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
+sub to_utf8 {
+ my $str = shift;
+ if (utf8::valid($str)) {
+ utf8::decode($str);
+ return $str;
+ } else {
+ return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
+ }
+}
+
## ----------------------------------------------------------------------
## HTML aware string manipulation