... | ... |
@@ -45,6 +45,8 @@ sub startup { |
45 | 45 |
|
46 | 46 |
# Git |
47 | 47 |
my $git = Gitprep::Git->new; |
48 |
+ $git->app($self); |
|
49 |
+ weaken $git->{app}; |
|
48 | 50 |
my $git_bin |
49 | 51 |
= $conf->{basic}{git_bin} ? $conf->{basic}{git_bin} : $git->search_bin; |
50 | 52 |
if (!$git_bin || ! -e $git_bin) { |
... | ... |
@@ -58,12 +60,13 @@ sub startup { |
58 | 60 |
|
59 | 61 |
# Encoding suspects list for Git |
60 | 62 |
my $encoding_suspects |
61 |
- = $conf->{basic}{encoding_suspects} ||= 'utf8'; |
|
63 |
+ = $conf->{basic}{encoding_suspects} ||= 'UTF-8'; |
|
62 | 64 |
$encoding_suspects = [split /,/, $encoding_suspects] unless ref $encoding_suspects eq 'ARRAY'; |
63 | 65 |
$git->encoding_suspects($encoding_suspects); |
64 | 66 |
|
65 | 67 |
# Repository Manager |
66 |
- my $manager = Gitprep::Manager->new(app => $self); |
|
68 |
+ my $manager = Gitprep::Manager->new; |
|
69 |
+ $manager->app($self); |
|
67 | 70 |
weaken $manager->{app}; |
68 | 71 |
$self->manager($manager); |
69 | 72 |
|
... | ... |
@@ -19,6 +19,7 @@ has 'encoding_suspects'; |
19 | 19 |
has 'rep_home'; |
20 | 20 |
has text_exts => sub { ['txt'] }; |
21 | 21 |
has 'time_zone_second'; |
22 |
+has 'app'; |
|
22 | 23 |
|
23 | 24 |
sub branch { |
24 | 25 |
my ($self, $user, $project, $branch_name) = @_; |
... | ... |
@@ -67,7 +68,9 @@ sub no_merged_branch_h { |
67 | 68 |
|
68 | 69 |
my @cmd = $self->cmd($user, $project, 'branch', '--no-merged'); |
69 | 70 |
open my $fh, '-|', @cmd or return; |
70 |
- while (my $branch_name = $self->_dec(scalar <$fh>)) { |
|
71 |
+ my @lines = <$fh>; |
|
72 |
+ for my $branch_name (@lines) { |
|
73 |
+ $branch_name = $self->_dec($branch_name); |
|
71 | 74 |
$branch_name =~ s/^\*//; |
72 | 75 |
$branch_name =~ s/^\s*//; |
73 | 76 |
$branch_name =~ s/\s*$//; |
... | ... |
@@ -87,7 +90,9 @@ sub branches { |
87 | 90 |
my $branches = []; |
88 | 91 |
my $start; |
89 | 92 |
my $no_merged_branches_h; |
90 |
- while (my $branch_name = $self->_dec(scalar <$fh>)) { |
|
93 |
+ my @lines = <$fh>; |
|
94 |
+ for my $branch_name (@lines) { |
|
95 |
+ $branch_name = $self->_dec($branch_name); |
|
91 | 96 |
$branch_name =~ s/^\*//; |
92 | 97 |
$branch_name =~ s/^\s*//; |
93 | 98 |
$branch_name =~ s/\s*$//; |
... | ... |
@@ -103,7 +108,6 @@ sub branches { |
103 | 108 |
} |
104 | 109 |
@$branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$branches; |
105 | 110 |
|
106 |
- |
|
107 | 111 |
return $branches; |
108 | 112 |
} |
109 | 113 |
|
... | ... |
@@ -151,7 +155,9 @@ sub authors { |
151 | 155 |
open my $fh, "-|", @cmd |
152 | 156 |
or croak 500, "Open git-cat-file failed"; |
153 | 157 |
my $authors = {}; |
154 |
- while (my $line = $self->_dec(<$fh>)) { |
|
158 |
+ my @lines = <$fh>; |
|
159 |
+ for my $line (@lines) { |
|
160 |
+ $line = $self->_dec($line); |
|
155 | 161 |
$line =~ s/[\r\n]//g; |
156 | 162 |
$authors->{$line} = 1; |
157 | 163 |
} |
... | ... |
@@ -184,7 +190,9 @@ sub blame { |
184 | 190 |
my $blame_line; |
185 | 191 |
my $max_author_time; |
186 | 192 |
my $min_author_time; |
187 |
- while (my $line = $self->_dec_guess(scalar <$fh>)) { |
|
193 |
+ my @lines = <$fh>; |
|
194 |
+ for my $line (@lines) { |
|
195 |
+ $line = $self->_dec_guess($line); |
|
188 | 196 |
chomp $line; |
189 | 197 |
|
190 | 198 |
if ($blame_line) { |
... | ... |
@@ -273,13 +281,15 @@ sub blob { |
273 | 281 |
or croak "Can't cat $file, $hash"; |
274 | 282 |
|
275 | 283 |
# Format lines |
276 |
- my $lines =[]; |
|
277 |
- while (my $line = $self->_dec_guess(scalar <$fh>)) { |
|
284 |
+ my @lines = <$fh>; |
|
285 |
+ my @new_lines; |
|
286 |
+ for my $line (@lines) { |
|
287 |
+ $line = $self->_dec_guess($line); |
|
278 | 288 |
chomp $line; |
279 |
- push @$lines, $line; |
|
289 |
+ push @new_lines, $line; |
|
280 | 290 |
} |
281 | 291 |
|
282 |
- return $lines; |
|
292 |
+ return \@new_lines; |
|
283 | 293 |
} |
284 | 294 |
|
285 | 295 |
sub blob_diffs { |
... | ... |
@@ -308,7 +318,9 @@ sub blob_diffs { |
308 | 318 |
open my $fh, '-|', @cmd |
309 | 319 |
or croak('Open self-diff-tree failed'); |
310 | 320 |
my @diff_tree; |
311 |
- while (my $line = $self->_dec_guess(scalar <$fh>)) { |
|
321 |
+ my @diff_treelines = <$fh>; |
|
322 |
+ for my $line (@diff_treelines) { |
|
323 |
+ $line = $self->_dec_guess($line); |
|
312 | 324 |
chomp $line; |
313 | 325 |
push @diff_tree, $line if $line =~ /^:/; |
314 | 326 |
last if $line =~ /^\n/; |
... | ... |
@@ -342,7 +354,8 @@ sub blob_diffs { |
342 | 354 |
); |
343 | 355 |
open my $fh, '-|', @cmd |
344 | 356 |
or croak('Open self-diff-tree failed'); |
345 |
- my @lines = map { $self->_dec_guess($_) } <$fh>; |
|
357 |
+ my @lines = <$fh>; |
|
358 |
+ @lines = map { $self->_dec_guess($_) } @lines; |
|
346 | 359 |
close $fh; |
347 | 360 |
my ($lines, $diff_info) = $self->parse_blob_diff_lines(\@lines); |
348 | 361 |
my $blob_diff = { |
... | ... |
@@ -442,7 +455,8 @@ sub blob_mode { |
442 | 455 |
); |
443 | 456 |
open my $fh, '-|', @cmd |
444 | 457 |
or croak 'Open git-ls-tree failed'; |
445 |
- my $line = $self->_dec(scalar <$fh>); |
|
458 |
+ my $line = <$fh>; |
|
459 |
+ $line = $self->_dec($line); |
|
446 | 460 |
close $fh or return; |
447 | 461 |
my ($mode) = ($line || '') =~ m/^([0-9]+) /; |
448 | 462 |
|
... | ... |
@@ -477,7 +491,8 @@ sub blob_size { |
477 | 491 |
); |
478 | 492 |
open my $fh, "-|", @cmd |
479 | 493 |
or croak 500, "Open cat-file failed"; |
480 |
- my $size = $self->_dec(scalar <$fh>); |
|
494 |
+ my $size = <$fh>; |
|
495 |
+ $size = $self->_dec($size); |
|
481 | 496 |
chomp $size; |
482 | 497 |
close $fh or croak 'Reading cat-file failed'; |
483 | 498 |
|
... | ... |
@@ -504,7 +519,8 @@ sub commits_number { |
504 | 519 |
my @cmd = $self->cmd($user, $project, 'shortlog', '-s', $ref); |
505 | 520 |
open my $fh, "-|", @cmd |
506 | 521 |
or croak 500, "Open git-shortlog failed"; |
507 |
- my @commits_infos = map { chomp; $self->_dec($_) } <$fh>; |
|
522 |
+ my @commits_infos = <$fh>; |
|
523 |
+ @commits_infos = map { chomp; $self->_dec($_) } @commits_infos; |
|
508 | 524 |
close $fh or croak 'Reading git-shortlog failed'; |
509 | 525 |
|
510 | 526 |
my $commits_num = 0; |
... | ... |
@@ -570,7 +586,8 @@ sub description { |
570 | 586 |
else { |
571 | 587 |
# Read description |
572 | 588 |
return unless -f $file; |
573 |
- my $description = $self->_dec($self->_slurp($file) || ''); |
|
589 |
+ my $description = $self->_slurp($file) || ''; |
|
590 |
+ $description = $self->_dec($description); |
|
574 | 591 |
return $description; |
575 | 592 |
} |
576 | 593 |
} |
... | ... |
@@ -600,7 +617,8 @@ sub diff_tree { |
600 | 617 |
|
601 | 618 |
open my $fh, "-|", @cmd |
602 | 619 |
or croak 500, "Open git-diff-tree failed"; |
603 |
- my @diff_tree = map { chomp; $self->_dec($_) } <$fh>; |
|
620 |
+ my @diff_tree = <$fh>; |
|
621 |
+ @diff_tree = map { chomp; $self->_dec($_) } @diff_tree; |
|
604 | 622 |
close $fh or croak 'Reading git-diff-tree failed'; |
605 | 623 |
|
606 | 624 |
# Parse "git diff-tree" output |
... | ... |
@@ -711,7 +729,8 @@ sub path_to_hash { |
711 | 729 |
); |
712 | 730 |
open my $fh, '-|', @cmd |
713 | 731 |
or croak 'Open git-ls-tree failed'; |
714 |
- my $line = $self->_dec(scalar <$fh>); |
|
732 |
+ my $line = <$fh>; |
|
733 |
+ $line = $self->_dec($line); |
|
715 | 734 |
close $fh or return; |
716 | 735 |
my ($t, $id) = ($line || '') =~ m/^[0-9]+ (.+) ([0-9a-fA-F]{40})\t/; |
717 | 736 |
$t ||= ''; |
... | ... |
@@ -734,7 +753,8 @@ sub last_activity { |
734 | 753 |
'--count=1', 'refs/heads' |
735 | 754 |
); |
736 | 755 |
open my $fh, '-|', @cmd or return; |
737 |
- my $most_recent = $self->_dec(scalar <$fh>); |
|
756 |
+ my $most_recent = <$fh>; |
|
757 |
+ $most_recent = $self->_dec($most_recent); |
|
738 | 758 |
close $fh or return; |
739 | 759 |
|
740 | 760 |
# Parse most recent |
... | ... |
@@ -771,9 +791,10 @@ sub path_by_id { |
771 | 791 |
|
772 | 792 |
# Get path |
773 | 793 |
local $/ = "\0"; |
774 |
- while (my $line = <$fh>) { |
|
775 |
- chomp $line; |
|
794 |
+ my @lines = <$fh>; |
|
795 |
+ for my $line (@lines) { |
|
776 | 796 |
$line = $self->_dec($line); |
797 |
+ chomp $line; |
|
777 | 798 |
|
778 | 799 |
if ($line =~ m/(?:[0-9]+) (?:.+) $hash\t(.+)$/) { |
779 | 800 |
close $fh; |
... | ... |
@@ -798,7 +819,9 @@ sub parse_rev_path { |
798 | 819 |
open my $fh, '-|', @cmd |
799 | 820 |
or return; |
800 | 821 |
my $refs = []; |
801 |
- while (my $line = $self->_dec(scalar <$fh>)) { |
|
822 |
+ my @lines = <$fh>; |
|
823 |
+ for my $line (@lines) { |
|
824 |
+ $line = $self->_dec($line); |
|
802 | 825 |
chomp $line; |
803 | 826 |
if ($line =~ m!^[0-9a-fA-F]{40}\s(refs/((?:heads|tags)/(.*)))$!) { |
804 | 827 |
push @$refs, $1, $2, $3; |
... | ... |
@@ -845,7 +868,8 @@ sub object_type { |
845 | 868 |
$rev |
846 | 869 |
); |
847 | 870 |
open my $fh, '-|', @cmd or return; |
848 |
- my $type = $self->_dec(scalar <$fh>); |
|
871 |
+ my $type = <$fh>; |
|
872 |
+ $type = $self->_dec($type); |
|
849 | 873 |
close $fh or return; |
850 | 874 |
chomp $type; |
851 | 875 |
|
... | ... |
@@ -868,7 +892,8 @@ sub project_urls { |
868 | 892 |
# Project URLs |
869 | 893 |
open my $fh, '<', "$project/cloneurl" |
870 | 894 |
or return; |
871 |
- my @urls = map { chomp; $self->_dec($_) } <$fh>; |
|
895 |
+ my @urls = <$fh>; |
|
896 |
+ @urls = map { chomp; $self->_dec($_) } @urls; |
|
872 | 897 |
close $fh; |
873 | 898 |
|
874 | 899 |
return \@urls; |
... | ... |
@@ -918,7 +943,9 @@ sub references { |
918 | 943 |
# Parse references |
919 | 944 |
my %refs; |
920 | 945 |
my $type_re = $type ? $type : '(?:heads|tags)'; |
921 |
- while (my $line = $self->_dec(scalar <$fh>)) { |
|
946 |
+ my @lines = <$fh>; |
|
947 |
+ for my $line (@lines) { |
|
948 |
+ $line = $self->_dec($line); |
|
922 | 949 |
chomp $line; |
923 | 950 |
if ($line =~ m!^([0-9a-fA-F]{40})\srefs/$type_re/(.*)$!) { |
924 | 951 |
my $rev = $1; |
... | ... |
@@ -1005,7 +1032,9 @@ sub tags { |
1005 | 1032 |
# Parse Tags |
1006 | 1033 |
my @tags; |
1007 | 1034 |
my $line_num = 1; |
1008 |
- while (my $line = $self->_dec(scalar <$fh>)) { |
|
1035 |
+ my @lines = <$fh>; |
|
1036 |
+ for my $line (@lines) { |
|
1037 |
+ $line = $self->_dec($line); |
|
1009 | 1038 |
|
1010 | 1039 |
if ($line_num > $offset && $line_num < $offset + $count + 1) { |
1011 | 1040 |
|
... | ... |
@@ -1092,7 +1121,8 @@ sub last_change_commit { |
1092 | 1121 |
or croak 'Open git-log failed'; |
1093 | 1122 |
|
1094 | 1123 |
local $/; |
1095 |
- my $commit_log_text = $self->_dec(scalar <$fh>); |
|
1124 |
+ my $commit_log_text = <$fh>; |
|
1125 |
+ $commit_log_text = $self->_dec($commit_log_text); |
|
1096 | 1126 |
|
1097 | 1127 |
my $commit; |
1098 | 1128 |
if ($commit_log_text =~ /^([0-9a-zA-Z]+)/) { |
... | ... |
@@ -1202,7 +1232,8 @@ sub get_commit { |
1202 | 1232 |
|
1203 | 1233 |
# Parse commit |
1204 | 1234 |
local $/ = "\0"; |
1205 |
- my $content = $self->_dec(scalar <$fh>); |
|
1235 |
+ my $content = <$fh>; |
|
1236 |
+ $content = $self->_dec($content); |
|
1206 | 1237 |
return unless defined $content; |
1207 | 1238 |
my $commit = $self->parse_commit_text($content, 1); |
1208 | 1239 |
close $fh; |
... | ... |
@@ -1339,7 +1370,9 @@ sub get_commits { |
1339 | 1370 |
# Prase Commits text |
1340 | 1371 |
local $/ = "\0"; |
1341 | 1372 |
my @commits; |
1342 |
- while (my $line = $self->_dec(scalar <$fh>)) { |
|
1373 |
+ my @lines = <$fh>; |
|
1374 |
+ for my $line (@lines) { |
|
1375 |
+ $line = $self->_dec($line); |
|
1343 | 1376 |
my $commit = $self->parse_commit_text($line); |
1344 | 1377 |
push @commits, $commit; |
1345 | 1378 |
} |
... | ... |
@@ -1593,7 +1626,8 @@ sub trees { |
1593 | 1626 |
or $self->croak('Open git-ls-tree failed'); |
1594 | 1627 |
{ |
1595 | 1628 |
local $/ = "\0"; |
1596 |
- @entries = map { chomp; $self->_dec($_) } <$fh>; |
|
1629 |
+ @entries = <$fh>; |
|
1630 |
+ @entries = map { chomp; $self->_dec($_) } @entries; |
|
1597 | 1631 |
} |
1598 | 1632 |
close $fh |
1599 | 1633 |
or $self->croak(404, "Reading tree failed"); |