Showing 6 changed files with 37 additions and 38 deletions
+7 -5
lib/Gitprep/Git.pm
... ...
@@ -713,14 +713,16 @@ sub file_type_long {
713 713
 }
714 714
 
715 715
 sub forward_commits {
716
-  my ($self, $rep_info, $rev1, $rev2) = @_;
717
-  
716
+  my ($self, $work_rep_info, $base_rep_info, $base_branch, $target_rep_info, $target_branch) = @_;
717
+
718
+  my $target_object_id = $self->app->git->ref_to_object_id($target_rep_info, $target_branch);
719
+
718 720
   # Forwarding commits
719 721
   my @cmd = $self->cmd(
720
-    $rep_info,
722
+    $work_rep_info,
721 723
     'rev-list',
722 724
     '--left-right',
723
-    "$rev1...$rev2"
725
+    "$base_branch...$target_object_id"
724 726
   );
725 727
   open my $fh, '-|', @cmd
726 728
     or croak "Can't get info: @cmd";
... ...
@@ -728,7 +730,7 @@ sub forward_commits {
728 730
   while (my $line = <$fh>) {
729 731
     if ($line =~ /^>(.+)\s/) {
730 732
       my $rev = $1;
731
-      my $commit = $self->get_commit($rep_info, $rev);
733
+      my $commit = $self->get_commit($work_rep_info, $rev);
732 734
       push @$commits, $commit;
733 735
     }
734 736
   }
+1
lib/Gitprep/Manager.pm
... ...
@@ -28,6 +28,7 @@ sub prepare_merge {
28 28
   
29 29
   # Fetch target repository
30 30
   my @git_fetch_target_cmd = $self->app->git->cmd($work_rep_info, 'fetch', $target_rep_info->{git_dir});
31
+  
31 32
   Gitprep::Util::run_command(@git_fetch_target_cmd)
32 33
     or Carp::croak "Can't execute git fetch: @git_fetch_target_cmd";
33 34
 
+14 -8
templates/compare.html.ep
... ...
@@ -194,7 +194,14 @@
194 194
   }
195 195
   
196 196
   # Commits
197
-  my $commits = $git->forward_commits($base_rep_info, $base_branch, $target_branch);
197
+  my $commits = $git->forward_commits(
198
+    $work_rep_info,
199
+    $base_rep_info,
200
+    $base_branch,
201
+    $target_rep_info,
202
+    $target_branch
203
+  );
204
+
198 205
   my $commits_count = @$commits;
199 206
   my $commits_date = {};
200 207
   my $authors = {};
... ...
@@ -207,12 +214,12 @@
207 214
   my $authors_count = keys %$authors;
208 215
 
209 216
   # Start commit
210
-  my $start_commit = $git->separated_commit($base_rep_info, $base_branch, $target_branch);
217
+  my $start_commit_id = app->git->ref_to_object_id($base_rep_info, $base_branch);
211 218
 
212 219
   # End commit
213
-  my $end_commit = $git->get_commit($target_rep_info, $target_branch);
220
+  my $end_commit_id = app->git->ref_to_object_id($target_rep_info, $target_branch);
214 221
   
215
-  if (!$start_commit || !$end_commit) {
222
+  if (!$start_commit_id || !$end_commit_id) {
216 223
     $self->reply->not_found;
217 224
     return;
218 225
   }
... ...
@@ -237,10 +244,9 @@
237 244
   
238 245
   # commit_body args
239 246
   my %commit_body_args = (
240
-    id => $end_commit->{id},
241
-    from_id => $start_commit->{id},
242
-    rev => $end_commit->{id},
243
-    from_rev => $start_commit->{id}
247
+    rep_info => $work_rep_info,
248
+    rev => $end_commit_id,
249
+    from_rev => $start_commit_id
244 250
   );
245 251
 
246 252
   layout 'common', title => "Comparing $base_branch...$target_branch \x{30fb} $base_user_id/$base_project_id";
+3 -2
templates/include/commit_body.html.ep
... ...
@@ -1,5 +1,6 @@
1 1
 <%
2 2
   # Parameters
3
+  my $rep_info = stash('rep_info') // app->rep_info($user, $project);
3 4
   my $rev = stash('rev');
4 5
   my $from_rev = stash('from_rev');
5 6
 
... ...
@@ -20,7 +21,7 @@
20 21
   
21 22
   # Diff tree
22 23
   my $diff_trees = $git->diff_tree(
23
-    app->rep_info($user, $project),
24
+    $rep_info,
24 25
     $rev,
25 26
     $from_rev,
26 27
     {ignore_space_change => $ignore_space_change}
... ...
@@ -35,7 +36,7 @@
35 36
   
36 37
   # Get blob diffs
37 38
   my $blob_diffs = $git->blob_diffs(
38
-    app->rep_info($user, $project),
39
+    $rep_info,
39 40
     $from_rev,
40 41
     $rev,
41 42
     $diff_trees,
+12 -7
templates/pull.html.ep
... ...
@@ -219,7 +219,13 @@
219 219
   }
220 220
   
221 221
   # Commits
222
-  my $commits = $git->forward_commits($base_rep_info, $base_branch, $target_branch);
222
+  my $commits = $git->forward_commits(
223
+    $work_rep_info,
224
+    $base_rep_info,
225
+    $base_branch,
226
+    $target_rep_info,
227
+    $target_branch
228
+  );
223 229
   my $commits_count = @$commits;
224 230
   my $commits_date = {};
225 231
   my $authors = {};
... ...
@@ -232,10 +238,10 @@
232 238
   my $authors_count = keys %$authors;
233 239
 
234 240
   # Start commit
235
-  my $start_commit = $git->separated_commit($base_rep_info, $base_branch, $target_branch);
241
+  my $start_commit_id = app->git->ref_to_object_id($base_rep_info, $base_branch);
236 242
 
237 243
   # End commit
238
-  my $end_commit = $git->get_commit($target_rep_info, $target_branch);
244
+  my $end_commit_id = app->git->ref_to_object_id($target_rep_info, $target_branch);
239 245
   
240 246
   # Issue messages
241 247
   my $issue_messages = app->dbi->model('issue_message')->select(
... ...
@@ -297,10 +303,9 @@
297 303
   
298 304
   # Commit body arguments
299 305
   my %commit_body_args = (
300
-    id => $end_commit->{id},
301
-    from_id => $start_commit->{id},
302
-    rev => $end_commit->{id},
303
-    from_rev => $start_commit->{id}
306
+    rep_info => $work_rep_info,
307
+    rev => $end_commit_id,
308
+    from_rev => $start_commit_id
304 309
   );
305 310
 
306 311
   layout 'common', title => "Pull Requests Tags \x{30fb} $base_user_id/$base_project_id";
-16
xt/basic.t
... ...
@@ -414,22 +414,6 @@ note 'Markdown normal file';
414 414
   $t->content_like(qr#<h1 .*?>Head</h1>#);
415 415
 }
416 416
 
417
-note 'Compare page';
418
-{
419
-  # Page access (branch name)
420
-  $t->get_ok("/$user/$project/compare/b1...master");
421
-  $t->content_like(qr#renamed dir/a\.txt to dir/b\.txt and added text#);
422
-
423
-  # Page access (branch name long)
424
-  $t->get_ok("/$user/$project/compare/refs/heads/b1...refs/heads/master");
425
-  $t->content_like(qr#renamed dir/a\.txt to dir/b\.txt and added text#);
426
-
427
-  # Page access
428
-  $t->get_ok("/$user/$project/compare/master...no_merged");
429
-  $t->content_like(qr/branch change/);
430
-  $t->content_like(qr#http://foo5branch change#);
431
-}
432
-
433 417
 note 'Search page';
434 418
 {
435 419
   # Page access (branch name)