« blib/lib/App/Prove/Elasticsearch/Harness.pm
↑ Summary
blib/lib/App/Prove/Elasticsearch/Provisioner/Perl.pm »
| 1 | package App::Prove::Elasticsearch::Provisioner::Git; | ||||||||||
| 2 | 3 | $App::Prove::Elasticsearch::Provisioner::Git::VERSION = '0.001'; | |||||||||
| 3 | |||||||||||
| 4 | # PODNAME: App::Prove::Elasticsearch::Provisioner::Git; | ||||||||||
| 5 | # ABSTRACT: Provision new versions to test using git | ||||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 3 | ▶ | use App::perlbrew; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | ▶ | use Perl::Version; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 3 | ▶ | use Capture::Tiny qw{capture_stderr}; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 3 | ▶ | use Git; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | sub get_available_provision_targets { | ||||||||
|
Subroutine
get_available_provision_targets: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 16 | 1 | my ($cv) = @_; | |||||||||
| 17 | 1 | my @bs = Git::command(qw{rev-parse --abbrev-ref --all}); | |||||||||
| 18 | 0 | ▶ | @bs = grep { $cv ne $_ } @bs if $cv; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 1 | return @bs; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 1 | ▶ | sub pick_platform { | ||||||||
|
Subroutine
pick_platform: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 23 | 1 | my (@plats) = @_; | |||||||||
| 24 | |||||||||||
| 25 | 1 | my $plat; | |||||||||
| 26 | 1 | foreach my $p (@plats) { | |||||||||
| 27 | 1 | my @cmd = (qw{git reflog show}, $p); | |||||||||
| 28 | 1 | my $ref_exists; | |||||||||
| 29 | 1 | ▶ | capture_stderr { $ref_exists = Git::command(@cmd) }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 1 | ▶ | if ($ref_exists) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 1 | $plat = $p; | |||||||||
| 32 | 1 | @plats = grep { $_ ne $p } @plats; | |||||||||
| 33 | 1 | last; | |||||||||
| 34 | } | ||||||||||
| 35 | } | ||||||||||
| 36 | 1 | return $plat, \@plats; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 2 | ▶ | sub can_switch_version { | ||||||||
|
Subroutine
can_switch_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 40 | 2 | my $versioner = shift; | |||||||||
| 41 | 2 | return $versioner eq 'App::Prove::Elasticsearch::Versioner::Git'; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 2 | ▶ | sub switch_version_to { | ||||||||
|
Subroutine
switch_version_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 45 | 2 | my $version_to = shift; | |||||||||
| 46 | 2 | return Git::command(qw{reset --hard}, $version_to); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 3 | *provision = \&switch_version_to; | |||||||||
| 50 | |||||||||||
| 51 | 3 | 1; | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||