blib/lib/App/karr/Cmd/Destroy.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/App/karr/Cmd/Delete.pm ↑ Summary blib/lib/App/karr/Cmd/SetRefs.pm »
1 # ABSTRACT: Destroy the ref-backed karr board
2  
3 package App::karr::Cmd::Destroy;
4 our $VERSION = '0.602';
5 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use MooX::Options (
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 usage_string => 'USAGE: karr destroy --yes',
9 1 );
10 1 ▶use App::karr::Error qw( command_hint );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 0 ▶use App::karr::Role::BoardDiscovery;
Subroutine BEGIN: called CC=1 SCAR=2.6
12 use App::karr::Role::CliArgs;
13 use App::karr::Role::SyncLifecycle;
14  
15 with 'App::karr::Role::BoardDiscovery';
16 with 'App::karr::Role::SyncLifecycle';
17 with 'App::karr::Role::CliArgs';
18  
19  
20 option yes => (
21 is => 'ro',
22 short => 'y',
23 doc => 'Acknowledge destructive deletion of refs/karr/*',
24 );
25  
26 sub execute {
27 my ($self, $args_ref, $chain_ref) = @_;
28  
29 die "Board destroy is destructive and deletes refs/karr/*. Re-run with --yes.\n"
30 unless $self->yes;
31  
32 # store honours --dir (both call forms) and dies loudly if the target is
33 # not a Git repository, instead of hardcoding the current directory.
34 my $store = $self->store;
35  
36 # Destroy deletes refs/karr/*: run the full sync lifecycle so the pull (which
37 # may bring a remote-only board into view before we decide it is missing) and
38 # the push that publishes those deletions both retry, and the guard insures
39 # the push on a crash.
40 $self->sync_before;
41  
42 # The one spelling of this sentence, shared with require_board and with
43 # destroy/materialize/repair: the way out is a command on its own last line
44 # (ticket k263).
45 die "No karr board found:\n" . command_hint('init') . "\n"
46 unless $store->has_board_refs;
47  
48 $store->delete_all_karr_refs;
49  
50 $self->sync_after;
51  
52 print STDERR "Deleted refs/karr/*\n";
53 }
54  
55 1;
56  
57 __END__
« blib/lib/App/karr/Cmd/Delete.pm ↑ Summary blib/lib/App/karr/Cmd/SetRefs.pm »