| 1 | # PODNAME: Luv::CLI::Git | ||||||||||
| 2 | # ABSTRACT: git operations for fetching and updating library dependencies | ||||||||||
| 3 | |||||||||||
| 4 | 2 | ▶ | use v5.38; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use Object::Pad; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use IPC::Run qw(run); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | class Luv::CLI::Git; | ||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | method clone ( $url, $dest, $ref = undef ) { | ||||||||
|
Subroutine
clone: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||
| 12 | 1 | my @cmd = ( 'git', 'clone', $url, $dest ); | |||||||||
| 13 | 1 | my ( $out, $err ); | |||||||||
| 14 | 1 | ▶ | IPC::Run::run( \@cmd, \undef, \$out, \$err ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | or die "git clone failed for '$url':\n$err"; | ||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | if ( defined $ref ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | $self->checkout( $dest, $ref ); | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 1 | return 1; | |||||||||
| 22 | 2 | } | |||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | method checkout ( $dest, $ref ) { | ||||||||
|
Subroutine
checkout: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 25 | 0 | my @cmd = ( 'git', '-C', $dest, 'checkout', $ref ); | |||||||||
| 26 | 0 | my ( $out, $err ); | |||||||||
| 27 | 0 | ▶ | IPC::Run::run( \@cmd, \undef, \$out, \$err ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | or die "git checkout '$ref' failed in '$dest':\n$err"; | ||||||||||
| 29 | |||||||||||
| 30 | 0 | return 1; | |||||||||
| 31 | 2 | } | |||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | method pull ($dest) { | ||||||||
|
Subroutine
pull: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 34 | 0 | my @cmd = ( 'git', '-C', $dest, 'pull' ); | |||||||||
| 35 | 0 | my ( $out, $err ); | |||||||||
| 36 | 0 | ▶ | IPC::Run::run( \@cmd, \undef, \$out, \$err ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | or die "git pull failed in '$dest':\n$err"; | ||||||||||
| 38 | |||||||||||
| 39 | 0 | return 1; | |||||||||
| 40 | 2 | } | |||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | method current_ref ($dest) { | ||||||||
|
Subroutine
current_ref: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 43 | 1 | my @cmd = ( 'git', '-C', $dest, 'rev-parse', 'HEAD' ); | |||||||||
| 44 | 1 | my ( $out, $err ); | |||||||||
| 45 | 1 | ▶ | IPC::Run::run( \@cmd, \undef, \$out, \$err ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | or die "git rev-parse failed in '$dest':\n$err"; | ||||||||||
| 47 | |||||||||||
| 48 | 1 | chomp $out; | |||||||||
| 49 | 1 | return $out; | |||||||||
| 50 | 2 | } | |||||||||
| 51 | |||||||||||
| 52 | 2 | 1; | |||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||