blib/lib/Yukki/Model/Repository.pm

filter: Statementstmt 26.0% 66 / 253 Branchbran 1.4% 1 / 68 Conditioncond 6.6% 1 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 36.9% 17 / 46 Podpod 100% 27 / 27 totaltotal 26.7% 112 / 418 CC 48 SCAR 45.0
CC
48
Cov
20%
make_tree
380.0
log
56.0
diff_blobs
56.0
CRAP 89.6
↑ Summary blib/lib/Yukki/Web/Router/Route.pm »
1 package Yukki::Model::Repository;
2 6 $Yukki::Model::Repository::VERSION = '0.991_007'; # TRIAL
3 6 $Yukki::Model::Repository::VERSION = '0.991007';
4 6 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 extends 'Yukki::Model';
9  
10 6 ▶use Yukki::Error qw( http_throw );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use Yukki::Model::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 6 ▶use DateTime::Format::Mail;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use Git::Repository v1.18;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use Type::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 6 ▶use Types::Path::Tiny qw( Path );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 6 ▶use Types::Standard qw( Bool Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
18 6 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 6 ▶use Yukki::Types qw( RepositoryName );
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 6 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # ABSTRACT: model for accessing objects in a git repository
24  
25  
26 6 has name => (
27 is => 'ro',
28 isa => RepositoryName,
29 required => 1,
30 );
31  
32  
33 has is_master_repository => (
34 is => 'ro',
35 isa => Bool,
36 required => 1,
37 lazy => 1,
38 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 my $self = shift;
40 0 defined $self->app->settings->repositories->{ $self->name }
41 },
42 6 );
43  
44  
45 has repository_settings => (
46 is => 'ro',
47 isa => class_type('Yukki::Settings::Repository'),
48 required => 1,
49 lazy => 1,
50 33 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=7.9
51 33 my $self = shift;
52 33 my $repo_config = $self->app->settings->repositories->{$self->name};
53  
54 33 ▶ if (!$repo_config) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repo_config) 0 33 33
55 0 my $file = $self->app->locate('repo_path', $self->name);
56 0 $repo_config = Yukki::Settings::Repository->load_yaml(
57 $file->slurp_utf8
58 );
59 }
60  
61 33 return $repo_config;
62 },
63 6 handles => {
64 'title' => 'name',
65 'branch' => 'site_branch',
66 },
67 );
68  
69  
70 6 has repository_path => (
71 is => 'ro',
72 isa => Path,
73 coerce => 1,
74 required => 1,
75 lazy => 1,
76 builder => '_build_repository_path',
77 );
78  
79 5 ▶sub _build_repository_path {
Subroutine _build_repository_path: called CC=1 SCAR=0.0
80 5 my $self = shift;
81  
82 5 my $repo_settings = $self->repository_settings;
83 5 return $self->locate_dir('repository_path', $repo_settings->repository);
84 }
85  
86  
87 6 has git => (
88 is => 'ro',
89 isa => class_type('Git::Repository'),
90 required => 1,
91 lazy => 1,
92 builder => '_build_git',
93 );
94  
95 5 ▶sub _build_git {
Subroutine _build_git: called CC=1 SCAR=0.0
96 5 my $self = shift;
97 5 return Git::Repository->new( git_dir => $self->repository_path );
98 }
99  
100  
101 0 ▶sub resolve_ref {
Subroutine resolve_ref: not called CC=3 SCAR=24.8
Pod documented
102 0 my ($self, $ref) = @_;
103 0 ▶ return $self->branch unless defined $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ref 0 0 0
104 0 ▶ return $self->branch if $ref eq 'HEAD';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "HEAD" 0 0 0
105 0 return $ref;
106 }
107  
108  
109 0 ▶sub repository_exists {
Subroutine repository_exists: not called CC=1 SCAR=6.9
Pod documented
110 0 my $self = shift;
111 0 return $self->repository_path->exists;
112 }
113  
114  
115 0 ▶sub author_name { shift->app->settings->anonymous->author_name }
Subroutine author_name: not called CC=1 SCAR=6.9
Pod documented
116  
117  
118 0 ▶sub author_email { shift->app->settings->anonymous->author_email }
Subroutine author_email: not called CC=1 SCAR=6.9
Pod documented
119  
120  
121 0 ▶sub make_tree {
Subroutine make_tree: not called CC=19 SCAR=59.4
Pod documented
122 0 my $self = shift;
123 0 my $base = shift;
124 0 my $path = shift;
125  
126 0 my (@new_path, @old_path, $blob);
127  
128 # This is a rename
129 0 ▶ if (ref $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 0 0 0
130 0 my $new_path = shift;
131 0 $blob = shift;
132 0 @new_path = @$new_path;
133 0 @old_path = @$path;
134 }
135  
136 # Otherwise it's a store or delete
137 else {
138 0 $blob = shift;
139  
140 # Defined $blob -> Store
141 0 ▶ if (defined $blob) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $blob) { } 0 0 0
142 0 @new_path = @$path;
143 }
144  
145 # Undefined $blob -> delete
146 else {
147 0 @old_path = @$path;
148 }
149 }
150  
151 0 my ($new_mode, $new_type, $new_name, $old_name, $remove_here);
152  
153 # Parts to add or update
154 0 ▶ if (@new_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (@new_path) 0 0 0
155 0 $new_name = shift @new_path;
156  
157 # Create the file here?
158 0 ▶ if (@new_path == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@new_path == 0) { } 0 0 0
159 0 $new_mode = '100644';
160 0 $new_type = 'blob';
161 }
162  
163 # Or we're still hunting down the tree
164 else {
165 0 $new_mode = '040000';
166 0 $new_type = 'tree';
167 }
168 }
169  
170 # Parts to remove
171 0 ▶ if (@old_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (@old_path) 0 0 0
172 0 $old_name = shift @old_path;
173 0 $remove_here = (@old_path == 0);
174 }
175  
176 0 my $git = $self->git;
177  
178 0 my $overwrite;
179 my @new_tree;
180 0 ▶ if (defined $base) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $base) 0 0 0
181 0 my @old_tree = $git->run('ls-tree', $base);
182 0 for my $line (@old_tree) {
183 0 my ($old_mode, $old_type, $old_object_id, $old_file) = split /\s+/, $line, 4;
184  
185 0 ▶ if (defined $new_name and $old_file eq $new_name) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $new_name and $old_file eq $new_name) { } 0 0 0
elsif (defined $old_name and $old_file eq $old_name) { } 0 0 0
Condition0%0/3
defined $new_name and $old_file eq $new_name
!ll&&!rl&&r
000
MC/DC0%0/2
defined $new_name and $old_file eq $new_name
defined $new_name $old_file eq $new_name
Truth table0%0/3
A and B
A= defined $new_nameB= $old_file eq $new_name
ABresult
0X0
100
111
186  
187 # The file already exists, we are doing an update
188 0 $overwrite++;
189  
190 # Cannot overwrite a file with a dir or a dir with a file
191 0 ▶ http_throw("cannot replace $old_type $new_name with $new_type")
Branch: 1 branch
BranchTrueFalseTotal
if $old_type ne $new_type 0 0 0
192 if $old_type ne $new_type;
193  
194  
195 # Add the updated file to the tree
196 0 ▶ if ($new_type eq 'blob') {
Branch: 2 branches
BranchTrueFalseTotal
if ($new_type eq 'blob') { } 0 0 0
elsif ($old_name eq $new_name) { } 0 0 0
197 0 push @new_tree, "$new_mode $new_type $blob\t$new_name";
198 }
199  
200 # The child tree contains both sides of the rename
201 elsif ($old_name eq $new_name) {
202 0 my $tree_id = $self->make_tree($old_object_id, \@old_path, \@new_path, $blob);
203 0 push @new_tree, "$new_mode $new_type $tree_id\t$new_name";
204 }
205  
206 # Add the updated tree contains only the rename/add
207 else {
208 0 my $tree_id = $self->make_tree($old_object_id, \@new_path, $blob);
209 0 push @new_tree, "$new_mode $new_type $tree_id\t$new_name";
210 }
211 }
212  
213 # If $old_name != $new_name and it matches this file
214 ▶ elsif (defined $old_name and $old_file eq $old_name) {
Condition0%0/3
defined $old_name and $old_file eq $old_name
!ll&&!rl&&r
000
MC/DC0%0/2
defined $old_name and $old_file eq $old_name
defined $old_name $old_file eq $old_name
Truth table0%0/3
A and B
A= defined $old_nameB= $old_file eq $old_name
ABresult
0X0
100
111
215  
216 # if ($remove_here) { ... do nothing ... }. The file will be
217 # omitted. \o/
218  
219 # Not yet removed, but we need to hunt it down and remove it
220 0 ▶ unless ($remove_here) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($remove_here) 0 0 0
221 0 my $tree_id = $self->make_tree($old_object_id, \@old_path);
222 0 push @new_tree, "040000 tree $tree_id\t$old_name";
223 }
224 }
225  
226 # It's something else, leave it be.
227 else {
228 0 push @new_tree, $line;
229 }
230 }
231 }
232  
233 # If the file or tree we want to create was never encountered, add it
234 0 ▶ if ($new_name and not $overwrite) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_name and not $overwrite) 0 0 0
Condition0%0/3
$new_name and not $overwrite
!ll&&!rl&&r
000
MC/DC0%0/2
$new_name and not $overwrite
$new_name not $overwrite
Truth table0%0/3
A and not(B)
A= $new_nameB= not $overwrite
ABresult
0X0
100
111
235  
236 # ...as a file
237 0 ▶ if ($new_type eq 'blob') {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_type eq 'blob') { } 0 0 0
238 0 push @new_tree, "$new_mode $new_type $blob\t$new_name";
239 }
240  
241 # ...as a tree
242 else {
243 0 my $tree_id = $self->make_tree(undef, \@new_path, $blob);
244 0 push @new_tree, "$new_mode $new_type $tree_id\t$new_name";
245 }
246 }
247  
248 # Now, build this new tree from the input we've generated
249 0 return $git->run('mktree', { input => join "\n", @new_tree });
250 }
251  
252  
253 0 ▶sub make_blob {
Subroutine make_blob: not called CC=1 SCAR=6.9
Pod documented
254 0 my ($self, $name, $content) = @_;
255  
256 0 return $self->git->run('hash-object', '-t', 'blob', '-w', '--stdin', '--path', $name,
257 { input => $content });
258 }
259  
260  
261 0 ▶sub make_blob_from_file {
Subroutine make_blob_from_file: not called CC=1 SCAR=6.9
Pod documented
262 0 my ($self, $name, $filename) = @_;
263  
264 0 return $self->git->run('hash-object', '-t', 'blob', '-w', '--path', $name, $filename);
265 }
266  
267  
268 0 ▶sub find_root {
Subroutine find_root: not called CC=3 SCAR=24.8
Pod documented
269 0 my ($self) = @_;
270  
271 0 my $old_tree_id;
272 0 my @ref_info = $self->git->run('show-ref', $self->branch);
273 0 REF: for my $line (@ref_info) {
274 0 my ($object_id, $name) = split /\s+/, $line, 2;
275  
276 0 ▶ if ($name eq $self->branch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq $self->branch) 0 0 0
277 0 $old_tree_id = $object_id;
278 0 last REF;
279 }
280 }
281  
282 0 return $old_tree_id;
283 }
284  
285  
286 0 ▶sub commit_tree {
Subroutine commit_tree: not called CC=2 SCAR=17.9
Pod documented
287 0 my ($self, $old_tree_id, $new_tree_id, $comment) = @_;
288  
289 0 ▶ return $self->git->run(
Condition0%0/2
$comment // ""
l!l
00
MC/DC0%0/1
$comment // ""
$comment
Truth table0%0/2
A
A= $comment
Aresult
11
00
290 'commit-tree', $new_tree_id, '-p', $old_tree_id, {
291 input => $comment // '',
292 env => {
293 GIT_AUTHOR_NAME => $self->author_name,
294 GIT_AUTHOR_EMAIL => $self->author_email,
295 },
296 },
297 );
298 }
299  
300  
301 0 ▶sub update_root {
Subroutine update_root: not called CC=1 SCAR=6.9
Pod documented
302 0 my ($self, $old_commit_id, $new_commit_id) = @_;
303 0 $self->git->command('update-ref', $self->branch, $new_commit_id, $old_commit_id);
304 }
305  
306  
307 0 ▶sub find_path {
Subroutine find_path: not called CC=3 SCAR=24.8
Pod documented
308 0 my ($self, $path, $r) = @_;
309 0 $r = $self->resolve_ref($r);
310  
311 0 my $object_id;
312 my @files;
313 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
314 0 @files = $self->git->run('ls-tree', $r, $path);
315 }
316 0 ▶ catch {
Subroutine __ANON__: not called CC=2 SCAR=17.9
317  
318 # Looks like an empty repo, try initializing it
319 0 ▶ if ($_ =~ /Not a valid object name/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /Not a valid object name/u) { } 0 0 0
320 0 $self->initialize_repository;
321 0 @files = $self->git->run('ls-tree', $r, $path);
322 }
323  
324 # I don't know what this is, die die die!
325 else {
326 0 die $_;
327 }
328 0 };
329  
330 0 FILE: for my $line (@files) {
331 0 my ($mode, $type, $id, $name) = split /\s+/, $line, 4;
332  
333 0 ▶ if ($name eq $path) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq $path) 0 0 0
334 0 $object_id = $id;
335 0 last FILE;
336 }
337 }
338  
339 0 return $object_id;
340 }
341  
342  
343 0 ▶sub show {
Subroutine show: not called CC=1 SCAR=6.9
Pod documented
344 0 my ($self, $object_id) = @_;
345 0 return $self->git->run('show', $object_id);
346 }
347  
348  
349 0 ▶sub fetch_date {
Subroutine fetch_date: not called CC=2 SCAR=17.9
Pod documented
350 0 my ($self, $path, $r, $format) = @_;
351 0 $r = $self->resolve_ref($r);
352 0 ▶ $format //= 'format:%s';
Condition0%0/2
$format //= "format:%s"
l!l
00
MC/DC0%0/1
$format //= "format:%s"
$format
Truth table0%0/2
A
A= $format
Aresult
11
00
353  
354 0 return $self->git->run('log', "--date=$format", '-1', '--format=%ad', $r, '--', $path);
355 }
356  
357  
358 0 ▶sub fetch_size {
Subroutine fetch_size: not called CC=3 SCAR=24.8
Pod documented
359 0 my ($self, $path, $r) = @_;
360 0 $r = $self->resolve_ref($r);
361  
362 0 my @files = $self->git->run('ls-tree', '-l', $r, $path);
363 0 FILE: for my $line (@files) {
364 0 my ($mode, $type, $id, $size, $name) = split /\s+/, $line, 5;
365 0 ▶ return $size if $name eq $path;
Branch: 1 branch
BranchTrueFalseTotal
if $name eq $path 0 0 0
366 }
367  
368 0 return;
369 }
370  
371  
372 0 ▶sub list_files {
Subroutine list_files: not called CC=4 SCAR=30.0
Pod documented
373 0 my ($self, $path, $r) = @_;
374 0 $r = $self->resolve_ref($r);
375 0 my @files;
376  
377 0 my @tree_files = $self->git->run('ls-tree', $r, $path . '/');
378 0 FILE: for my $line (@tree_files) {
379 0 my ($mode, $type, $id, $name) = split /\s+/, $line, 4;
380  
381 0 ▶ next unless $type eq 'blob';
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "blob" 0 0 0
382  
383 0 my $filetype;
384 0 ▶ if ($name =~ s/\.(?<filetype>[a-z0-9]+)$//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s/\.(?<filetype>[a-z0-9]+)$//u) 0 0 0
385 0 $filetype = $+{filetype};
386 }
387  
388 0 push @files, $self->file({ path => $name, filetype => $filetype });
389 }
390  
391 0 return @files;
392 }
393  
394  
395 0 ▶sub file {
Subroutine file: not called CC=1 SCAR=6.9
Pod documented
396 0 my ($self, $params) = @_;
397  
398 0 Yukki::Model::File->new(
399 %$params,
400 app => $self->app,
401 repository => $self,
402 );
403 }
404  
405  
406 0 ▶sub default_file {
Subroutine default_file: not called CC=1 SCAR=6.9
Pod documented
407 0 my $self = shift;
408  
409 0 return Yukki::Model::File->new(
410 full_path => $self->repository_settings->default_page,
411 app => $self->app,
412 repository => $self,
413 );
414 }
415  
416  
417 0 ▶sub log {
Subroutine log: not called CC=7 SCAR=40.3
Pod documented
418 0 my ($self, $full_path, $r) = @_;
419 0 $r = $self->resolve_ref($r);
420  
421 0 my @lines = $self->git->run(
422 'log', $r, '--pretty=format:%H~%an~%aD~%ar~%s', '--numstat',
423 '--', $full_path
424 );
425  
426 0 my @revisions;
427 my $current_revision;
428  
429 0 my $mode = 'log';
430 0 for my $line (@lines) {
431  
432 # First line is the log line
433 0 ▶ if ($mode eq 'log') {
Branch: 3 branches
BranchTrueFalseTotal
if ($mode eq 'log') { } 0 0 0
elsif ($mode eq 'stat') { } 0 0 0
elsif ($mode eq 'skip') { } 0 0 0
434 0 $current_revision = {};
435  
436 0 @{ $current_revision }{qw( object_id author_name date time_ago comment )}
437 = split /~/, $line, 5;
438  
439 $current_revision->{date} = DateTime::Format::Mail->parse_datetime(
440 $current_revision->{date}
441 0 );
442  
443 0 $mode = 'stat';
444 }
445  
446 # Remaining lines are the numstat
447 elsif ($mode eq 'stat') {
448 0 my ($added, $removed, $path) = split /\s+/, $line, 3;
449 0 ▶ if ($path eq $full_path) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path eq $full_path) 0 0 0
450 0 $current_revision->{lines_added} = $added;
451 0 $current_revision->{lines_removed} = $removed;
452 }
453  
454 0 $mode = 'skip';
455 }
456  
457 # Once we know the numstat, search for the blank and start over
458 elsif ($mode eq 'skip') {
459 0 push @revisions, $current_revision;
460 0 ▶ $mode = 'log' if $line !~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /\S/u 0 0 0
461 }
462  
463 else {
464 0 http_throw("invalid parse mode '$mode'");
465 }
466 }
467  
468 0 return @revisions;
469 }
470  
471  
472 0 ▶sub diff_blobs {
Subroutine diff_blobs: not called CC=7 SCAR=40.3
Pod documented
473 0 my ($self, $path, $object_id_1, $object_id_2) = @_;
474  
475 0 my @lines = $self->git->run(
476 'diff', '--word-diff=porcelain', '--unified=10000000', '--patience',
477 $object_id_1, $object_id_2, '--', $path,
478 );
479  
480 0 my @chunks;
481 0 my $last_chunk_type = '';
482  
483 0 my $i = 0;
484 0 LINE: for my $line (@lines) {
485 0 ▶ next if $i++ < 5;
Branch: 1 branch
BranchTrueFalseTotal
if $i++ < 5 0 0 0
486  
487 0 my ($type, $detail) = $line =~ /^(.)(.*)$/;
488 0 ▶ if ($type =~ /^(?:~| |\+|-)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type =~ /^(?:~| |\+|-)$/u) { } 0 0 0
elsif ($type eq '\\') { } 0 0 0
489 0 ▶ if ($last_chunk_type eq $type) {
Branch: 2 branches
BranchTrueFalseTotal
if ($last_chunk_type eq $type) { } 0 0 0
elsif ($type eq '~') { } 0 0 0
490 0 $chunks[-1][1] .= $detail;
491 }
492 elsif ($type eq '~') {
493 0 $chunks[-1][1] .= "\n";
494 }
495 else {
496 0 push @chunks, [ $type, $detail ];
497 0 $last_chunk_type = $type;
498 }
499 }
500 elsif ($type eq '\\') { }
501 0 else { warn "unknown diff line type $type" }
502 }
503  
504 0 return @chunks;
505 }
506  
507  
508 5 ▶sub initialize_repository {
Subroutine initialize_repository: called CC=2 SCAR=7.3
Pod documented
509 5 my $self = shift;
510  
511 5 my $repository_path = ''.$self->repository_path;
512 5 Git::Repository->run('init', '--bare', $repository_path);
513  
514 # TODO This would be nice to have as a config.
515 5 ▶ my $title = $self->repository_settings->name // 'Untitled';
Condition50%1/2
$self->repository_settings->name // "Untitled"
l!l
50
MC/DC0%0/1
$self->repository_settings->name // "Untitled"
$self->repository_settings->name
Truth table50%1/2
A
A= $self->repository_settings->name
Aresult
11
00
516 5 my $stub_main = <<END_OF_STUB_MAIN;
517 # $title
518  
519 Welcome to your new wiki repository. The first thing you will probably
520 want to do is edit this page.
521  
522 Cheers.
523  
524 END_OF_STUB_MAIN
525  
526 5 my $page = $self->repository_settings->default_page;
527 5 my $object_id = $self->git->run('hash-object', '-t', 'blob', '-w', '--stdin', "--path=$page", { input => $stub_main });
528  
529 5 my $stub_tree = "100655 blob $object_id\t$page\n";
530 5 my $tree_id = $self->git->run('mktree', { input => $stub_tree });
531 5 my $commit_id = $self->git->run('commit-tree', $tree_id, {
532 input => 'Initializing empty Yukki repository.',
533 env => {
534 GIT_AUTHOR_NAME => 'Yukki::Model::Repository',
535 GIT_AUTHOR_EMAIL => 'hanenkamp@cpan.org',
536 },
537 });
538  
539 0 my $branch = $self->branch;
540 0 $self->git->run('update-ref', $branch, $commit_id, '0' x 40);
541  
542 0 return;
543 }
544  
545  
546 0 ▶sub clone_repository {
Subroutine clone_repository: not called CC=1 SCAR=6.9
Pod documented
547 0 my ($self, $origin) = @_;
548  
549 0 my $repository_path = ''.$self->repository_path;
550 0 Git::Repository->run('clone', '--bare', $origin, $repository_path);
551  
552 0 return;
553 }
554  
555  
556 0 ▶sub remote_config {
Subroutine remote_config: not called CC=1 SCAR=6.9
Pod documented
557 0 my $self = shift;
558 return +{
559 map {
560 0 my ($k, $v) = split /\s+/;
561 0 my ($r, $n, $u) = split /[.]/, $k, 3;
562 0 ($n, $v);
563 } $self->git->run('config', '--get-regex', 'remote\..*\.url')
564 };
565 }
566  
567  
568 0 ▶sub remote {
Subroutine remote: not called CC=2 SCAR=17.9
Pod documented
569 0 my ($self, $name) = @_;
570  
571 0 my $config = $self->remote_config;
572 return $self->app->model('Remote', {
573 repository => $self,
574 name => $name,
575 0 ▶ }) if defined $config->{ $name };
Branch: 1 branch
BranchTrueFalseTotal
if defined $config->{$name} 0 0 0
576  
577 0 return;
578 }
579  
580  
581 0 ▶sub add_remote_config {
Subroutine add_remote_config: not called CC=1 SCAR=6.9
Pod documented
582 0 my ($self, $name, $url) = @_;
583 0 $self->git->run('remote', $name, $url);
584 0 return;
585 }
586  
587  
588 0 ▶sub remove_remote_config {
Subroutine remove_remote_config: not called CC=1 SCAR=6.9
Pod documented
589 0 my ($self, $name) = @_;
590 0 $self->git->run('remote', 'remote', $name);
591 0 return;
592 }
593  
594  
595 0 ▶sub update_remote_config {
Subroutine update_remote_config: not called CC=1 SCAR=6.9
Pod documented
596 0 my ($self, $name, $url) = @_;
597 0 $self->git->run('remote', 'set-url', $name, $url);
598 0 return;
599 }
600  
601  
602 0 ▶sub fetch_remote {
Subroutine fetch_remote: not called CC=1 SCAR=6.9
Pod documented
603 0 my ($self, $name) = @_;
604 0 $self->git->run('fetch', $name);
605 0 return;
606 }
607  
608 6 1;
609  
610 __END__
↑ Summary blib/lib/Yukki/Web/Router/Route.pm »