Showing 6 changed files with 19 additions and 48 deletions
+14 -43
lib/Gitprep/Git.pm
... ...
@@ -226,7 +226,7 @@ sub blame {
226 226
   my $min_author_time;
227 227
   my @lines = <$fh>;
228 228
   
229
-  my $enc = $self->decide_encoding($rep_info->{user}, $rep_info->{project}, \@lines);
229
+  my $enc = $self->decide_encoding($rep_info, \@lines);
230 230
   for my $line (@lines) {
231 231
     $line = decode($enc, $line);
232 232
     chomp $line;
... ...
@@ -298,7 +298,7 @@ sub blob {
298 298
   # Format lines
299 299
   my @lines = <$fh>;
300 300
   my @new_lines;
301
-  my $enc = $self->decide_encoding($rep_info->{user}, $rep_info->{project}, \@lines);
301
+  my $enc = $self->decide_encoding($rep_info, \@lines);
302 302
   for my $line (@lines) {
303 303
     $line = decode($enc, $line);
304 304
     chomp $line;
... ...
@@ -334,7 +334,7 @@ sub blob_diffs {
334 334
     or croak('Open self-diff-tree failed');
335 335
   my @diff_tree;
336 336
   my @diff_tree_lines = <$fh>;
337
-  my $diff_tree_enc = $self->decide_encoding($rep_info->{user}, $rep_info->{project}, \@diff_tree_lines);
337
+  my $diff_tree_enc = $self->decide_encoding($rep_info, \@diff_tree_lines);
338 338
   for my $line (@diff_tree_lines) {
339 339
     $line = decode($diff_tree_enc, $line);
340 340
     chomp $line;
... ...
@@ -370,7 +370,7 @@ sub blob_diffs {
370 370
     open my $fh, '-|', @cmd
371 371
       or croak('Open self-diff-tree failed');
372 372
     my @lines = <$fh>;
373
-    my $enc = $self->decide_encoding($rep_info->{user}, $rep_info->{project}, \@lines);
373
+    my $enc = $self->decide_encoding($rep_info, \@lines);
374 374
     @lines = map { decode($enc, $_) } @lines;
375 375
     close $fh;
376 376
     my ($lines, $diff_info) = $self->parse_blob_diff_lines(\@lines);
... ...
@@ -910,27 +910,14 @@ sub short_id {
910 910
   return $self->id($project, @_, '--short=7');
911 911
 }
912 912
 
913
-sub tag {
914
-  my ($self, $project, $name) = @_;
915
-  
916
-  # Tag
917
-  my $tags = $self->tags($project);
918
-  for my $tag (@$tags) {
919
-    return $tag if $tag->{name} eq $name;
920
-  }
921
-  
922
-  return;
923
-}
924
-
925 913
 sub tags_count {
926
-  my ($self, $user, $project) = @_;
914
+  my ($self, $rep_info) = @_;
927 915
   
928 916
   my $limit = 1000;
929 917
   
930 918
   # Get tags
931
-  my @cmd = $self->cmd_rep(
932
-    $user,
933
-    $project,
919
+  my @cmd = $self->cmd(
920
+    $rep_info,
934 921
     'for-each-ref',
935 922
     ($limit ? '--count='.($limit+1) : ()),
936 923
     'refs/tags'
... ...
@@ -1018,30 +1005,14 @@ sub tags {
1018 1005
   return \@tags;
1019 1006
 }
1020 1007
 
1021
-sub is_deleted {
1022
-  my ($self, $diffinfo) = @_;
1023
-  
1024
-  # Check if deleted
1025
-  return $diffinfo->{to_id} eq ('0' x 40);
1026
-}
1027
-
1028
-sub id_set_multi {
1029
-  my ($self, $rev, $key, $value) = @_;
1030
-
1031
-  if (!exists $rev->{$key}) { $rev->{$key} = $value }
1032
-  elsif (!ref $rev->{$key}) { $rev->{$key} = [ $rev->{$key}, $value ] }
1033
-  else { push @{$rev->{$key}}, $value }
1034
-}
1035
-
1036 1008
 sub last_change_commit {
1037
-  my ($self, $user, $project, $rev, $file) = @_;
1009
+  my ($self, $rep_info, $rev, $file) = @_;
1038 1010
   
1039 1011
   my $commit_log = {};
1040 1012
   $file = '' unless defined $file;
1041 1013
   
1042
-  my @cmd = $self->cmd_rep(
1043
-    $user,
1044
-    $project,
1014
+  my @cmd = $self->cmd(
1015
+    $rep_info,
1045 1016
     '--no-pager',
1046 1017
     'log',
1047 1018
     '-n',
... ...
@@ -1061,7 +1032,7 @@ sub last_change_commit {
1061 1032
   my $commit;
1062 1033
   if ($commit_log_text =~ /^([0-9a-zA-Z]+)/) {
1063 1034
     my $rev = $1;
1064
-    $commit = $self->get_commit($user, $project, $rev);
1035
+    $commit = $self->get_commit_new($rep_info, $rev);
1065 1036
   }
1066 1037
   
1067 1038
   return $commit;
... ...
@@ -1604,7 +1575,7 @@ sub trees {
1604 1575
     
1605 1576
     # Commit log
1606 1577
     my $path = defined $dir && $dir ne '' ? "$dir/$tree->{name}" : $tree->{name};
1607
-    my $commit = $self->last_change_commit($user, $project, $rev, $path);
1578
+    my $commit = $self->last_change_commit($self->app->rep_info($user, $project), $rev, $path);
1608 1579
     $tree->{commit} = $commit;
1609 1580
     
1610 1581
     push @$trees, $tree;
... ...
@@ -1698,11 +1669,11 @@ sub _chop_str {
1698 1669
 }
1699 1670
 
1700 1671
 sub decide_encoding {
1701
-  my ($self, $user, $project, $lines) = @_;
1672
+  my ($self, $rep_info, $lines) = @_;
1702 1673
   
1703 1674
   my $guess_encoding_str = $self->app->dbi->model('project')->select(
1704 1675
     'guess_encoding',
1705
-    where => {user_id => $user, name => $project}
1676
+    where => {user_id => $rep_info->{user}, name => $rep_info->{project}}
1706 1677
   )->value;
1707 1678
   
1708 1679
   my @guess_encodings;
+1 -1
templates/blame.html.ep
... ...
@@ -12,7 +12,7 @@
12 12
   my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file);
13 13
 
14 14
   # Commit
15
-  my $commit = $git->last_change_commit($user, $project, $rev, $file);
15
+  my $commit = $git->last_change_commit(app->rep_info($user, $project), $rev, $file);
16 16
   
17 17
   # Authors
18 18
   my $authors = $git->authors(app->rep_info($user, $project), $rev, $file);
+1 -1
templates/blob.html.ep
... ...
@@ -14,7 +14,7 @@
14 14
   my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file);
15 15
 
16 16
   # Commit
17
-  my $commit = $git->last_change_commit($user, $project, $rev, $file);
17
+  my $commit = $git->last_change_commit(app->rep_info($user, $project), $rev, $file);
18 18
   my $commit_author_mail = $commit->{author_email};
19 19
   my $commit_author_id = app->dbi->model('user')->select(
20 20
     'id',
+1 -1
templates/pulls.html.ep
... ...
@@ -19,7 +19,7 @@
19 19
     $page_count,
20 20
     $page_count * ($page - 1)
21 21
   );
22
-  my $tags_count = $git->tags_count($user, $project);
22
+  my $tags_count = $git->tags_count(app->rep_info($user, $project));
23 23
 %>
24 24
 
25 25
 % layout 'common', title => "Tags \x{30fb} $user/$project";
+1 -1
templates/tags.html.ep
... ...
@@ -19,7 +19,7 @@
19 19
     $page_count,
20 20
     $page_count * ($page - 1)
21 21
   );
22
-  my $tags_count = $git->tags_count($user, $project);
22
+  my $tags_count = $git->tags_count(app->rep_info($user, $project));
23 23
 %>
24 24
 
25 25
 % layout 'common', title => "Tags \x{30fb} $user/$project";
+1 -1
templates/tree.html.ep
... ...
@@ -73,7 +73,7 @@
73 73
   my $branches = stash('branches');
74 74
   my $branches_count = app->git->branches_count($self->app->rep_info($user, $project));
75 75
   my $default_branch_name = app->manager->default_branch($user, $project);
76
-  my $tags_count = app->git->tags_count($user, $project);
76
+  my $tags_count = app->git->tags_count(app->rep_info($user, $project));
77 77
   
78 78
   my $logined = $api->logined;
79 79