... | ... |
@@ -462,11 +462,18 @@ sub id { |
462 | 462 |
} |
463 | 463 |
|
464 | 464 |
sub id_by_path { |
465 |
- my ($self, $project, $commit_id, $path, $type) = @_; |
|
465 |
+ my ($self, $user, $project, $commit_id, $path, $type) = @_; |
|
466 | 466 |
|
467 | 467 |
# Get blob id or tree id (command "git ls-tree") |
468 | 468 |
$path =~ s#/+$##; |
469 |
- my @cmd = ($self->cmd($project), 'ls-tree', $commit_id, '--', $path); |
|
469 |
+ my @cmd = $self->_cmd( |
|
470 |
+ $user, |
|
471 |
+ $project, |
|
472 |
+ 'ls-tree', |
|
473 |
+ $commit_id, |
|
474 |
+ '--', |
|
475 |
+ $path |
|
476 |
+ ); |
|
470 | 477 |
open my $fh, '-|', @cmd |
471 | 478 |
or croak 'Open git-ls-tree failed'; |
472 | 479 |
my $line = $self->dec(scalar <$fh>); |
... | ... |
@@ -775,15 +782,23 @@ sub id_set_multi { |
775 | 782 |
} |
776 | 783 |
|
777 | 784 |
sub latest_commit_log { |
778 |
- my ($self, $rep, $ref, $file) = @_; |
|
785 |
+ my ($self, $user, $project, $ref, $file) = @_; |
|
779 | 786 |
|
780 | 787 |
my $commit_log = {}; |
781 | 788 |
$file = '' unless defined $file; |
782 | 789 |
|
783 |
- my @cmd = ($self->cmd($rep), '--no-pager', 'log', |
|
784 |
- '-n', '1', |
|
790 |
+ my @cmd = $self->_cmd( |
|
791 |
+ $user, |
|
792 |
+ $project, |
|
793 |
+ '--no-pager', |
|
794 |
+ 'log', |
|
795 |
+ '-n', |
|
796 |
+ '1', |
|
785 | 797 |
'--pretty=format:%H - %an - %ar : %s', |
786 |
- $ref, '--', $file); |
|
798 |
+ $ref, |
|
799 |
+ '--', |
|
800 |
+ $file |
|
801 |
+ ); |
|
787 | 802 |
open my $fh, '-|', @cmd |
788 | 803 |
or croak 'Open git-log failed'; |
789 | 804 |
|
... | ... |
@@ -828,11 +843,19 @@ sub parse_blobdiff_lines { |
828 | 843 |
} |
829 | 844 |
|
830 | 845 |
sub parse_commit { |
831 |
- my ($self, $project, $id) = @_; |
|
846 |
+ my ($self, $user, $project, $id) = @_; |
|
832 | 847 |
|
833 | 848 |
# Git rev-list |
834 |
- my @cmd = ($self->cmd($project), 'rev-list', '--parents', |
|
835 |
- '--header', '--max-count=1', $id, '--'); |
|
849 |
+ my @cmd = $self->_cmd( |
|
850 |
+ $user, |
|
851 |
+ $project, |
|
852 |
+ 'rev-list', |
|
853 |
+ '--parents', |
|
854 |
+ '--header', |
|
855 |
+ '--max-count=1', |
|
856 |
+ $id, |
|
857 |
+ '--' |
|
858 |
+ ); |
|
836 | 859 |
open my $fh, '-|', @cmd |
837 | 860 |
or croak 'Open git-rev-list failed'; |
838 | 861 |
|
... | ... |
@@ -1280,13 +1303,20 @@ sub timestamp { |
1280 | 1303 |
} |
1281 | 1304 |
|
1282 | 1305 |
sub trees { |
1283 |
- my ($self, $rep, $tid, $ref, $dir) = @_; |
|
1306 |
+ my ($self, $user, $project, $tid, $ref, $dir) = @_; |
|
1284 | 1307 |
|
1285 |
- # Get tree (command "git ls-tree") |
|
1308 |
+ # Get tree |
|
1286 | 1309 |
my @entries = (); |
1287 | 1310 |
my $show_sizes = 0; |
1288 |
- open my $fh, '-|', $self->cmd($rep), 'ls-tree', '-z', |
|
1289 |
- ($show_sizes ? '-l' : ()), $tid |
|
1311 |
+ my @cmd = $self->_cmd( |
|
1312 |
+ $user, |
|
1313 |
+ $project, |
|
1314 |
+ 'ls-tree', |
|
1315 |
+ '-z', |
|
1316 |
+ ($show_sizes ? '-l' : ()), |
|
1317 |
+ $tid |
|
1318 |
+ ); |
|
1319 |
+ open my $fh, '-|', @cmd |
|
1290 | 1320 |
or $self->croak('Open git-ls-tree failed'); |
1291 | 1321 |
{ |
1292 | 1322 |
local $/ = "\0"; |
... | ... |
@@ -1303,7 +1333,7 @@ sub trees { |
1303 | 1333 |
|
1304 | 1334 |
# Commit log |
1305 | 1335 |
my $name = defined $dir && $dir ne '' ? "$dir/$tree->{name}" : $tree->{name}; |
1306 |
- my $commit_log = $self->latest_commit_log($rep, $ref, $name); |
|
1336 |
+ my $commit_log = $self->latest_commit_log($user, $project, $ref, $name); |
|
1307 | 1337 |
$tree = {%$tree, %$commit_log}; |
1308 | 1338 |
|
1309 | 1339 |
push @$trees, $tree; |
... | ... |
@@ -1,10 +1,8 @@ |
1 | 1 |
<% |
2 |
- use Gitprep::API; |
|
3 |
- |
|
4 | 2 |
my $state; |
5 | 3 |
|
6 | 4 |
# API |
7 |
- my $api = Gitprep::API->new($self); |
|
5 |
+ my $api = gitprep_api; |
|
8 | 6 |
|
9 | 7 |
# Default revision |
10 | 8 |
my $rev = 'master'; |
... | ... |
@@ -32,18 +30,18 @@ |
32 | 30 |
|
33 | 31 |
# Tree id |
34 | 32 |
my $tid; |
35 |
- my $commit = $git->parse_commit($rep, $id); |
|
33 |
+ my $commit = $git->parse_commit($user, $project, $id); |
|
36 | 34 |
if (defined $dir && $dir ne '') { |
37 |
- $tid = $git->id_by_path($rep, $id, $dir, 'tree'); |
|
35 |
+ $tid = $git->id_by_path($user, $project, $id, $dir, 'tree'); |
|
38 | 36 |
} |
39 | 37 |
else { $tid = $commit->{tree} } |
40 | 38 |
$self->render_not_found unless defined $tid; |
41 | 39 |
|
42 | 40 |
# Commit log |
43 |
- my $latest_commit_log = $git->latest_commit_log($rep, $rev); |
|
41 |
+ my $latest_commit_log = $git->latest_commit_log($user, $project, $rev); |
|
44 | 42 |
|
45 | 43 |
# Tree |
46 |
- my $trees = $git->trees($rep, $tid, $rev); |
|
44 |
+ my $trees = $git->trees($user, $project, $tid, $rev); |
|
47 | 45 |
|
48 | 46 |
# Repository description |
49 | 47 |
$desc = $git->description($user, $project); |