| ... | ... |
@@ -62,6 +62,8 @@ sub authors {
|
| 62 | 62 |
sub blobdiffs {
|
| 63 | 63 |
my ($self, $user, $project, $from_id, $id, $difftrees) = @_; |
| 64 | 64 |
|
| 65 |
+ return unless defined $from_id; |
|
| 66 |
+ |
|
| 65 | 67 |
my $blobdiffs = []; |
| 66 | 68 |
my @cmd = $self->cmd( |
| 67 | 69 |
$user, |
| ... | ... |
@@ -505,7 +507,7 @@ sub references {
|
| 505 | 507 |
); |
| 506 | 508 |
|
| 507 | 509 |
open my $fh, '-|', @cmd |
| 508 |
- or croak "Can't execute git show-ref"; |
|
| 510 |
+ or return; |
|
| 509 | 511 |
|
| 510 | 512 |
# Parse references |
| 511 | 513 |
my %refs; |
| ... | ... |
@@ -516,7 +518,7 @@ sub references {
|
| 516 | 518 |
else { $refs{$1} = [$2] }
|
| 517 | 519 |
} |
| 518 | 520 |
} |
| 519 |
- close $fh or croak "Can't read git show-ref"; |
|
| 521 |
+ close $fh or return; |
|
| 520 | 522 |
|
| 521 | 523 |
return \%refs; |
| 522 | 524 |
} |
| ... | ... |
@@ -1218,7 +1220,7 @@ sub _age_string {
|
| 1218 | 1220 |
my ($self, $age) = @_; |
| 1219 | 1221 |
my $age_str; |
| 1220 | 1222 |
|
| 1221 |
- if ($age > 60*60*24*365*2) {
|
|
| 1223 |
+ if ($age > 60 * 60 * 24 * 365 * 2) {
|
|
| 1222 | 1224 |
$age_str = (int $age/60/60/24/365); |
| 1223 | 1225 |
$age_str .= ' years ago'; |
| 1224 | 1226 |
} elsif ($age > 60*60*24*(365/12)*2) {
|
| ... | ... |
@@ -32,7 +32,7 @@ |
| 32 | 32 |
); |
| 33 | 33 |
|
| 34 | 34 |
# Get blob diffs |
| 35 |
- my $blobdiffs = $git->blobdiffs($user, $project, $from_id, $id, $difftrees); |
|
| 35 |
+ my $blobdiffs = $git->blobdiffs($user, $project, $from_id, $id, $difftrees) || []; |
|
| 36 | 36 |
|
| 37 | 37 |
# Branches |
| 38 | 38 |
my $branch_refs = $git->references($user, $project, 'heads'); |
| ... | ... |
@@ -48,6 +48,8 @@ |
| 48 | 48 |
id => $id, |
| 49 | 49 |
commit => $commit |
| 50 | 50 |
); |
| 51 |
+ |
|
| 52 |
+ use D;d $commit; |
|
| 51 | 53 |
%> |
| 52 | 54 |
|
| 53 | 55 |
% layout 'common'; |
| ... | ... |
@@ -0,0 +1,21 @@ |
| 1 |
+use Test::More 'no_plan'; |
|
| 2 |
+ |
|
| 3 |
+use FindBin; |
|
| 4 |
+use lib "$FindBin::Bin/../mojo/lib"; |
|
| 5 |
+use lib "$FindBin::Bin/../lib"; |
|
| 6 |
+use lib "$FindBin::Bin/../extlib/lib/perl5"; |
|
| 7 |
+ |
|
| 8 |
+use Test::Mojo; |
|
| 9 |
+use Gitprep; |
|
| 10 |
+ |
|
| 11 |
+my $app = Gitprep->new; |
|
| 12 |
+my $t = Test::Mojo->new($app); |
|
| 13 |
+ |
|
| 14 |
+my $user = 'kimoto'; |
|
| 15 |
+my $project = 'gitprep_t'; |
|
| 16 |
+ |
|
| 17 |
+# First commit |
|
| 18 |
+subtest 'first commit' => sub {
|
|
| 19 |
+ $t->get_ok("/$user/$project/commit/4b0e81c462088b16fefbe545e00b993fd7e6f884");
|
|
| 20 |
+}; |
|
| 21 |
+ |