Showing 2 changed files with 36 additions and 15 deletions
+19 -7
lib/Gitprep/Git.pm
... ...
@@ -266,10 +266,16 @@ sub branch_exists {
266 266
 }
267 267
 
268 268
 sub branch_commits {
269
-  my ($self, $rep, $rev1, $rev2) = @_;
269
+  my ($self, $user, $project, $rev1, $rev2) = @_;
270 270
   
271
-  # Command "git diff-tree"
272
-  my @cmd = ($self->cmd($rep), 'show-branch', $rev1, $rev2);
271
+  # Get bramcj commits
272
+  my @cmd = $self->_cmd(
273
+    $user,
274
+    $project,
275
+    'show-branch',
276
+    $rev1,
277
+    $rev2
278
+  );
273 279
   open my $fh, "-|", @cmd
274 280
     or croak 500, "Open git-show-branch failed";
275 281
 
... ...
@@ -283,7 +289,7 @@ sub branch_commits {
283 289
       
284 290
       next unless $id =~ /^\Q$rev2\E\^?$/ || $id =~ /^\Q$rev2\E^[0-9]+$/;
285 291
       
286
-      my $commit = $self->parse_commit($rep, $id);
292
+      my $commit = $self->parse_commit($user, $project, $id);
287 293
       
288 294
       push @$commits, $commit;
289 295
     }
... ...
@@ -300,10 +306,16 @@ sub branch_commits {
300 306
 }
301 307
 
302 308
 sub separated_commit {
303
-  my ($self, $rep, $rev1, $rev2) = @_;
309
+  my ($self, $user, $project, $rev1, $rev2) = @_;
304 310
   
305 311
   # Command "git diff-tree"
306
-  my @cmd = ($self->cmd($rep), 'show-branch', $rev1, $rev2);
312
+  my @cmd = $self->_cmd(
313
+    $user,
314
+    $project,
315
+    'show-branch',
316
+    $rev1,
317
+    $rev2
318
+  );
307 319
   open my $fh, "-|", @cmd
308 320
     or croak 500, "Open git-show-branch failed";
309 321
 
... ...
@@ -314,7 +326,7 @@ sub separated_commit {
314 326
   my $commit;
315 327
   if (defined $last_line) {
316 328
       my ($id) = $last_line =~ /^.*?\[(.+)?\]/;
317
-      $commit = $self->parse_commit($rep, $id);
329
+      $commit = $self->parse_commit($user, $project, $id);
318 330
   }
319 331
 
320 332
   return $commit;
+17 -8
templates/main/compare.html.ep
... ...
@@ -10,14 +10,12 @@
10 10
   my $rev2 = param('rev2');
11 11
   my $page = param('page') || 0;
12 12
   my $root_ns = $api->root_ns(config->{root});
13
-  my $rep_ns = "$root_ns/$user/$project.git";
14
-  my $rep = "/$rep_ns";
15 13
   
16 14
   # Git
17 15
   my $git = $self->app->git;
18 16
   
19 17
   # Commits
20
-  my $commits = $git->branch_commits($rep, $rev1, $rev2);
18
+  my $commits = $git->branch_commits($user, $project, $rev1, $rev2);
21 19
   my $commits_count = @$commits;
22 20
   my $commits_date = {};
23 21
   my $authors = {};
... ...
@@ -30,18 +28,29 @@
30 28
   my $authors_count = keys %$authors;
31 29
 
32 30
   # Start commit
33
-  my $start_commit = $git->separated_commit($rep, $rev1, $rev2);
31
+  my $start_commit = $git->separated_commit($user, $project, $rev1, $rev2);
34 32
 
35 33
   # End commit
36
-  my $end_commit = $git->parse_commit($rep, $rev2)
34
+  my $end_commit = $git->parse_commit($user, $project, $rev2)
37 35
     or $api->croak('Unknown commit object');
38 36
   
39 37
   # Diff tree
40
-  my $difftrees = $git->difftree($rep,
41
-    ,$end_commit->{id}, $start_commit->{id}, []);
38
+  my $difftrees = $git->difftree(
39
+    $user,
40
+    $project,
41
+    $end_commit->{id},
42
+    $start_commit->{id},
43
+    []
44
+  );
42 45
   
43 46
   # Get blob diffs (command "git diff-tree")
44
-  my $blobdiffs = $git->blobdiffs($rep, $start_commit->{id}, $end_commit->{id}, $difftrees);
47
+  my $blobdiffs = $git->blobdiffs(
48
+    $user,
49
+    $project,
50
+    $start_commit->{id},
51
+    $end_commit->{id},
52
+    $difftrees
53
+  );
45 54
   
46 55
   # Global variable
47 56
   stash(user => $user, project => $project);