| 1 | # ex:ts=8 sw=4: | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # $OpenBSD$ | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Copyright (c) 2026 Dick Olsson <hi@senzilla.io> | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # Permission to use, copy, modify, and distribute this software for any | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # purpose with or without fee is hereby granted, provided that the above | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # copyright notice and this permission notice appear in all copies. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | package App::FuguBench::Doctor; | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 117 | our $VERSION = '0.1.1'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 117 | ▶ | use v5.34; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 117 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 117 | ▶ | use experimental 'signatures'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 117 | ▶ | no feature qw(indirect multidimensional bareword_filehandles); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 117 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 117 | ▶ | use JSON::PP (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 117 | ▶ | use Fugu::CLI qw(EXIT_SUCCESS EXIT_ERROR); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 117 | ▶ | use Fugu::Curl; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 117 | ▶ | use Fugu::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 117 | ▶ | use Fugu::Process; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 117 | ▶ | use App::FuguBench::Hook; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 117 | ▶ | use App::FuguBench::Version; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 117 | ▶ | use App::FuguBench::Wiki; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | # App::FuguBench::Doctor - the doctor verb. | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # | ||||||||||||||||||||||||||||||||||||||||||
| 40 | # The verb reports the state of one checkout (CLI-DOCTOR-1): the | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # version of the program, the tools on PATH, the hook entries of the | ||||||||||||||||||||||||||||||||||||||||||
| 42 | # settings file, and the library clone. Each check writes one line to | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # standard output, and the verb returns 1 when it wrote a problem | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # line, so a make target can gate on the report (CLI-DOCTOR-3). | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # The verb reads the state, and --fix repairs one shape of it: the | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # debris of the open race, a clone that sits in a stopped rebase over | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # a session page with no observation (CLI-DOCTOR-2). Every other | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # pending commit is a refusal, and the operator resolves that rebase. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # The report holds the facts of the other verbs. The version line | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # comes from the version verb. The settings path, the keys of that | ||||||||||||||||||||||||||||||||||||||||||
| 53 | # file, the entries, and the worktree settings come from the hook | ||||||||||||||||||||||||||||||||||||||||||
| 54 | # verb, so this module holds no assumption of Claude Code (D-10). The | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # shape of a session page and the body of one come from the wiki | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # verb. | ||||||||||||||||||||||||||||||||||||||||||
| 57 | # | ||||||||||||||||||||||||||||||||||||||||||
| 58 | # The library directory is the one fact that this module reads for | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # itself. It reads the two keys that the wiki verb reads | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # (CLI-CONFIG-2), and a key that names no library gives one report | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # line here. The wiki verb reports the reason on its own call. | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | # The tools of the report (CLI-DOCTOR-1). git drives every clone, and | ||||||||||||||||||||||||||||||||||||||||||
| 64 | # make drives every gate. | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 117 | my @TOOLS = qw(git make); | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | # The encoder of the hook comparison. It sorts the keys, so two equal | ||||||||||||||||||||||||||||||||||||||||||
| 68 | # entries give two equal strings, and the comparison reads a nested | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # entry without a walk of its own. | ||||||||||||||||||||||||||||||||||||||||||
| 70 | # | ||||||||||||||||||||||||||||||||||||||||||
| 71 | # It takes the bytes and it handles the UTF-8 itself, as the hook | ||||||||||||||||||||||||||||||||||||||||||
| 72 | # verb does. An :encoding layer loads the PerlIO::encoding extension, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | # and the row of the verb gives no promise for the load of a shared | ||||||||||||||||||||||||||||||||||||||||||
| 74 | # object. | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 117 | my $JSON = JSON::PP->new->utf8->canonical; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | # App::FuguBench::Doctor->command($verb): | ||||||||||||||||||||||||||||||||||||||||||
| 78 | # The entry of the Fugu::CLI table. The module holds one verb, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | # so it ignores the name. | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 117 | ▶ | sub command ( $, $ ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 83 | summary => 'report the state of the checkout and its tools', | ||||||||||||||||||||||||||||||||||||||||||
| 84 | usage => '[--fix]', | ||||||||||||||||||||||||||||||||||||||||||
| 85 | options => { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | fix => 'skip the pending commit of a stopped' | ||||||||||||||||||||||||||||||||||||||||||
| 87 | . ' rebase in the library', | ||||||||||||||||||||||||||||||||||||||||||
| 88 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | run => sub ( $app, @argv ) { return _run( $app, @argv ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 117 | }; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | # _run($app, @argv): | ||||||||||||||||||||||||||||||||||||||||||
| 94 | # The body of the verb. It takes no argument, and every check | ||||||||||||||||||||||||||||||||||||||||||
| 95 | # writes its line to standard output. | ||||||||||||||||||||||||||||||||||||||||||
| 96 | # | ||||||||||||||||||||||||||||||||||||||||||
| 97 | # The verb reads the settings file and the library of one | ||||||||||||||||||||||||||||||||||||||||||
| 98 | # checkout, so an absent .toolingrc stops it with a | ||||||||||||||||||||||||||||||||||||||||||
| 99 | # configuration error (CLI-CHECKOUT-3). | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub _run ( $app, @argv ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return $app->cli->command_usage_error('doctor') if @argv; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $checkout = $app->checkout; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | return Fugu::CLI::EXIT_CONFIG_ERROR() unless $checkout; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my @lines = ( | |||||||||||||||||||||||||||||||||||||||||
| 108 | _version(), _tools(), | ||||||||||||||||||||||||||||||||||||||||||
| 109 | _hooks( $app, $checkout ), | ||||||||||||||||||||||||||||||||||||||||||
| 110 | _library( $app, $checkout ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | say for @lines; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my @problems = grep { index( $_, 'problem ' ) == 0 } @lines; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | return @problems ? EXIT_ERROR : EXIT_SUCCESS; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | # _ok($check, $detail): | ||||||||||||||||||||||||||||||||||||||||||
| 119 | # The line of a check that holds. | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub _ok ( $check, $detail ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ok: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | return "ok $check: $detail"; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | # _problem($check, $detail): | ||||||||||||||||||||||||||||||||||||||||||
| 126 | # The line of a check that fails. One such line makes the exit | ||||||||||||||||||||||||||||||||||||||||||
| 127 | # code of the verb 1 (CLI-DOCTOR-3). | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub _problem ( $check, $detail ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_problem: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return "problem $check: $detail"; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | # _version(): | ||||||||||||||||||||||||||||||||||||||||||
| 134 | # The version line of the program, as the version verb prints | ||||||||||||||||||||||||||||||||||||||||||
| 135 | # it. The check never fails: the program answers, so it runs. | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub _version () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_version: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | return _ok( 'version', App::FuguBench::Version->line ); | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | # _tools(): | ||||||||||||||||||||||||||||||||||||||||||
| 142 | # One line for each tool of the report. The detail of a tool | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # that answers is its path, so the operator sees which copy of | ||||||||||||||||||||||||||||||||||||||||||
| 144 | # it the program runs. | ||||||||||||||||||||||||||||||||||||||||||
| 145 | # | ||||||||||||||||||||||||||||||||||||||||||
| 146 | # Fugu::Curl searches curl, then wget, then the ftp(1) of | ||||||||||||||||||||||||||||||||||||||||||
| 147 | # OpenBSD, and it holds that order. So the downloader line names | ||||||||||||||||||||||||||||||||||||||||||
| 148 | # the command that a download runs (CLI-FUGU-1), and this module | ||||||||||||||||||||||||||||||||||||||||||
| 149 | # holds no second search list. | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub _tools () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tools: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | for my $name (@TOOLS) { | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $path = Fugu::Process->find_command($name); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | push @lines, defined $path | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | ? _ok( $name, $path ) | ||||||||||||||||||||||||||||||||||||||||||
| 157 | : _problem( $name, 'absent from PATH' ); | ||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $downloader = Fugu::Curl->new->command; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | push @lines, defined $downloader | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | ? _ok( 'downloader', $downloader ) | ||||||||||||||||||||||||||||||||||||||||||
| 163 | : _problem( 'downloader', 'no curl, wget, or ftp on PATH' ); | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | return @lines; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | # _hooks($app, $checkout): | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # The lines of the hook entries of the settings file that the | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # hook verb names (CLI-DOCTOR-1). A checkout that holds no | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # event of the four gives one line, ok hooks: none. Most | ||||||||||||||||||||||||||||||||||||||||||
| 172 | # checkouts install no hook, and that is no problem. | ||||||||||||||||||||||||||||||||||||||||||
| 173 | # | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # A checkout that holds one event of the four gives one line for | ||||||||||||||||||||||||||||||||||||||||||
| 175 | # each of the four, so the report names an event that the file | ||||||||||||||||||||||||||||||||||||||||||
| 176 | # lost. | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # | ||||||||||||||||||||||||||||||||||||||||||
| 178 | # A checkout that holds one event gives one worktree.baseRef | ||||||||||||||||||||||||||||||||||||||||||
| 179 | # line too, because hook install writes that value beside the | ||||||||||||||||||||||||||||||||||||||||||
| 180 | # entries (HOOK-INSTALL-4). A worktree key that holds no object | ||||||||||||||||||||||||||||||||||||||||||
| 181 | # gives the problem line of that key in its place. | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # | ||||||||||||||||||||||||||||||||||||||||||
| 183 | # The file that no read reaches, the file that holds no JSON | ||||||||||||||||||||||||||||||||||||||||||
| 184 | # object, and a container key that holds no object are problems, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | # because each one stops hook install. An absent file stops | ||||||||||||||||||||||||||||||||||||||||||
| 186 | # nothing. | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub _hooks ( $app, $checkout ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hooks: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $path = App::FuguBench::Hook->settings_path( $checkout->root ); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | return _ok( 'hooks', 'none' ) unless -e $path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $text = Fugu::File->read($path); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | return _problem( 'hooks', "cannot read $path" ) unless defined $text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $settings = eval { $JSON->decode($text) }; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | return _problem( 'hooks', "$path holds no JSON object" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | unless ref $settings eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $key = App::FuguBench::Hook->hooks_key; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | my $hooks = $settings->{$key} // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$settings->{$key} // {}
MC/DC0%0/1
$settings->{$key} // {}
$settings->{$key}
Truth table0%0/2
A
A= $settings->{$key}
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | return _problem( 'hooks', "$path: the $key key holds no object" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | unless ref $hooks eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $entries = App::FuguBench::Hook->entries; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my @named = grep { exists $hooks->{$_} } keys %$entries; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | my @lines = | ||||||||||||||||||||||||||||||||||||||||||
| 208 | @named | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | ? map { _same( "hook $_", $hooks->{$_}, $entries->{$_} ) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | sort keys %$entries | ||||||||||||||||||||||||||||||||||||||||||
| 211 | : _ok( 'hooks', 'none' ); | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return ( @lines, _worktree( $settings, $path, scalar @named ) ); | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | # _same($check, $found, $want): | ||||||||||||||||||||||||||||||||||||||||||
| 217 | # The line of one value of the settings file. The value of hook | ||||||||||||||||||||||||||||||||||||||||||
| 218 | # install is the measure, so the report and the write never | ||||||||||||||||||||||||||||||||||||||||||
| 219 | # disagree. | ||||||||||||||||||||||||||||||||||||||||||
| 220 | # | ||||||||||||||||||||||||||||||||||||||||||
| 221 | # The encoder takes a reference, and a value of another kind is | ||||||||||||||||||||||||||||||||||||||||||
| 222 | # no reference. So each value goes in a list of one, and every | ||||||||||||||||||||||||||||||||||||||||||
| 223 | # kind compares. | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub _same ( $check, $found, $want ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_same: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | return _problem( $check, 'absent' ) unless defined $found; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | return $JSON->encode( [$found] ) eq $JSON->encode( [$want] ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | ? _ok( $check, 'installed' ) | ||||||||||||||||||||||||||||||||||||||||||
| 230 | : _problem( $check, 'differs from hook install' ); | ||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | # _worktree($settings, $path, $installed): | ||||||||||||||||||||||||||||||||||||||||||
| 234 | # The lines of the worktree settings of hook install | ||||||||||||||||||||||||||||||||||||||||||
| 235 | # (HOOK-INSTALL-4). The subcommand writes them beside the | ||||||||||||||||||||||||||||||||||||||||||
| 236 | # entries. Without the hooks, a worktree of the harness starts | ||||||||||||||||||||||||||||||||||||||||||
| 237 | # at origin/main. | ||||||||||||||||||||||||||||||||||||||||||
| 238 | # | ||||||||||||||||||||||||||||||||||||||||||
| 239 | # A value line follows an install alone, because a checkout that | ||||||||||||||||||||||||||||||||||||||||||
| 240 | # installs no hook needs no value of that key. A key of another | ||||||||||||||||||||||||||||||||||||||||||
| 241 | # kind is a problem without one: it stops the install, as a | ||||||||||||||||||||||||||||||||||||||||||
| 242 | # container key of another kind does. | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub _worktree ( $settings, $path, $installed ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_worktree: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | { | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $key = App::FuguBench::Hook->worktree_key; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $found = $settings->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | return _problem( $key, "$path: the $key key holds no object" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $found and ref $found ne "HASH"
MC/DC0%0/2
defined $found and ref $found ne "HASH"
defined $found
ref $found ne "HASH"
Truth table0%0/3
A and B
A= defined $foundB= ref $found ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | if defined $found && ref $found ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | return () unless $installed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $want = App::FuguBench::Hook->worktree; | |||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | return map { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | _same( "$key.$_", ref $found eq 'HASH' ? $found->{$_} : undef, | |||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | $want->{$_} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | } sort keys %$want; | ||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | # _library($app, $checkout): | ||||||||||||||||||||||||||||||||||||||||||
| 260 | # The line of the library clone (CLI-DOCTOR-1). The clone | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # answers when it is clean, and the detail is then its path. | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # A stopped rebase comes first, because a clone in one holds a | ||||||||||||||||||||||||||||||||||||||||||
| 264 | # conflicted file, and the change list would name that file and | ||||||||||||||||||||||||||||||||||||||||||
| 265 | # hide the rebase. | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub _library ( $app, $checkout ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_library: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | { | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $dir = _dir($checkout); | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | return _ok( 'library', 'absent' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $dir and -d $dir and -e "$dir/.git"
defined $dir and -d $dir
MC/DC0%0/3
defined $dir and -d $dir and -e "$dir/.git"
defined $dir
-d $dir
-e "$dir/.git"
Truth table0%0/4
A and B and C
A= defined $dirB= -d $dirC= -e "$dir/.git"
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | unless defined $dir && -d $dir && -e "$dir/.git"; | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | return _rebase( $app, $dir ) if _stopped( $app, $dir ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $status = | |||||||||||||||||||||||||||||||||||||||||
| 275 | $app->command( [ 'git', 'status', '--porcelain' ], cwd => $dir ); | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return _problem( 'library', 'cannot read the clone: ' . $app->error ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | unless defined $status; | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my @changed = map { substr $_, 3 } split /\n/, $status; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | return _problem( 'library', 'changes ' . join( ', ', @changed ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | if @changed; | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | return _ok( 'library', $dir ); | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | # _dir($checkout): | ||||||||||||||||||||||||||||||||||||||||||
| 287 | # The library directory of the checkout, or undef. The home of | ||||||||||||||||||||||||||||||||||||||||||
| 288 | # wiki.origin anchors the value of wiki.dir, as it anchors every | ||||||||||||||||||||||||||||||||||||||||||
| 289 | # wiki. value (CLI-CONFIG-2), and the wiki verb reads the same | ||||||||||||||||||||||||||||||||||||||||||
| 290 | # two keys. | ||||||||||||||||||||||||||||||||||||||||||
| 291 | # | ||||||||||||||||||||||||||||||||||||||||||
| 292 | # The method gives undef for a checkout that names no library: a | ||||||||||||||||||||||||||||||||||||||||||
| 293 | # checkout without wiki.origin, a wiki.dir that fails the shape | ||||||||||||||||||||||||||||||||||||||||||
| 294 | # check, and a wiki.dir that resolves to the home itself | ||||||||||||||||||||||||||||||||||||||||||
| 295 | # (CLI-CONFIG-3). The report then names an absent library, and | ||||||||||||||||||||||||||||||||||||||||||
| 296 | # the wiki verb reports the reason on its own call. | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub _dir ($checkout) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dir: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my ( $origin, $home ) = $checkout->config('wiki.origin'); | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | return unless defined $origin; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my ($value) = $checkout->config('wiki.dir'); | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $name = $checkout->dir_value($value); | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | return unless defined $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $dir = File::Spec->catdir( $home, $name ); | |||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | return if $dir eq $home; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return $dir; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | # _stopped($app, $dir): | ||||||||||||||||||||||||||||||||||||||||||
| 313 | # True when the clone sits in a stopped rebase. git holds the | ||||||||||||||||||||||||||||||||||||||||||
| 314 | # state of one in a directory of the git directory: | ||||||||||||||||||||||||||||||||||||||||||
| 315 | # rebase-merge for the merge backend, and rebase-apply for the | ||||||||||||||||||||||||||||||||||||||||||
| 316 | # apply backend. | ||||||||||||||||||||||||||||||||||||||||||
| 317 | # | ||||||||||||||||||||||||||||||||||||||||||
| 318 | # REBASE_HEAD tells no stopped rebase. git writes that reference | ||||||||||||||||||||||||||||||||||||||||||
| 319 | # when a rebase stops, and a rebase that runs to its end leaves | ||||||||||||||||||||||||||||||||||||||||||
| 320 | # it behind. So the reference answers after the fix as it | ||||||||||||||||||||||||||||||||||||||||||
| 321 | # answers before it. | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub _stopped ( $app, $dir ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stopped: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | { | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $paths = $app->command( [ | |||||||||||||||||||||||||||||||||||||||||
| 325 | 'git', 'rev-parse', | ||||||||||||||||||||||||||||||||||||||||||
| 326 | '--git-path', 'rebase-merge', | ||||||||||||||||||||||||||||||||||||||||||
| 327 | '--git-path', 'rebase-apply' | ||||||||||||||||||||||||||||||||||||||||||
| 328 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 329 | cwd => $dir | ||||||||||||||||||||||||||||||||||||||||||
| 330 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | return 0 unless defined $paths; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | for my $path ( split /\n/, $paths ) { | |||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | # The directory goes in a variable first. On perl 5.34 a | ||||||||||||||||||||||||||||||||||||||||||
| 336 | # file test reads the class name of a method call as a | ||||||||||||||||||||||||||||||||||||||||||
| 337 | # bareword filehandle. | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $state = File::Spec->rel2abs( $path, $dir ); | |||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | return 1 if -d $state; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | # _rebase($app, $dir): | ||||||||||||||||||||||||||||||||||||||||||
| 346 | # The line of a clone that sits in a stopped rebase | ||||||||||||||||||||||||||||||||||||||||||
| 347 | # (CLI-DOCTOR-2). Without --fix the report names the pending | ||||||||||||||||||||||||||||||||||||||||||
| 348 | # commit and changes nothing. | ||||||||||||||||||||||||||||||||||||||||||
| 349 | # | ||||||||||||||||||||||||||||||||||||||||||
| 350 | # With --fix the verb runs git rebase --skip for a pending | ||||||||||||||||||||||||||||||||||||||||||
| 351 | # commit of the race shape, and it refuses every other one. The | ||||||||||||||||||||||||||||||||||||||||||
| 352 | # refusal holds the reason, so the operator reads what the | ||||||||||||||||||||||||||||||||||||||||||
| 353 | # commit carries before the manual repair. | ||||||||||||||||||||||||||||||||||||||||||
| 354 | # | ||||||||||||||||||||||||||||||||||||||||||
| 355 | # The fix takes one pending commit. A rebase of several commits | ||||||||||||||||||||||||||||||||||||||||||
| 356 | # stops again at the next one, and git exits 1 after that skip. | ||||||||||||||||||||||||||||||||||||||||||
| 357 | # The line then names the skip and the new stop, and it is a | ||||||||||||||||||||||||||||||||||||||||||
| 358 | # problem line: the clone needs the operator. The next run of | ||||||||||||||||||||||||||||||||||||||||||
| 359 | # the verb reports the new pending commit. | ||||||||||||||||||||||||||||||||||||||||||
| 360 | # | ||||||||||||||||||||||||||||||||||||||||||
| 361 | # A skip that leaves the same pending commit ran no skip, and | ||||||||||||||||||||||||||||||||||||||||||
| 362 | # the line is the refusal with the reason of git. | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | sub _rebase ( $app, $dir ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rebase: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | { | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my ( $page, $reason ) = _shape( $app, $dir ); | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | unless ( $app->cli->option('fix') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | return _problem( 'library', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | defined $page | ||||||||||||||||||||||||||||||||||||||||||
| 370 | ? "stopped rebase, the pending commit adds $page" | ||||||||||||||||||||||||||||||||||||||||||
| 371 | : "stopped rebase, $reason" ); | ||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | return _problem( 'library', "stopped rebase, fix refused: $reason" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | unless defined $page; | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $before = _pending( $app, $dir ); | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $app->command( [ 'git', 'rebase', '--skip' ], cwd => $dir ); | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $error = $app->error; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | return _ok( 'library', "skipped the pending commit $page" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | unless _stopped( $app, $dir ); | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my $after = _pending( $app, $dir ); | |||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | return _problem( 'library', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $after and !defined($before) || $after ne $before
not defined $before or $after ne $before
MC/DC0%0/3
defined $after and !defined($before) || $after ne $before
defined $after
not defined $before
$after ne $before
Truth table0%0/4
A and not(B) or C
A= defined $afterB= not defined $beforeC= $after ne $before
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | "skipped the pending commit $page, the rebase stopped again" ) | ||||||||||||||||||||||||||||||||||||||||||
| 386 | if defined $after && ( !defined $before || $after ne $before ); | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | return _problem( 'library', | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$error // "the pending commit stands"
MC/DC0%0/1
$error // "the pending commit stands"
$error
Truth table0%0/2
A
A= $error
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 'stopped rebase, fix refused: ' | ||||||||||||||||||||||||||||||||||||||||||
| 390 | . ( $error // 'the pending commit stands' ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | # _pending($app, $dir): | ||||||||||||||||||||||||||||||||||||||||||
| 394 | # The commit that REBASE_HEAD names, or undef. git writes that | ||||||||||||||||||||||||||||||||||||||||||
| 395 | # reference for the commit that a rebase stopped on. A skip that | ||||||||||||||||||||||||||||||||||||||||||
| 396 | # stopped again writes the next commit there, and a skip that | ||||||||||||||||||||||||||||||||||||||||||
| 397 | # ended the rebase leaves the reference on the commit it skipped. | ||||||||||||||||||||||||||||||||||||||||||
| 398 | # So the caller reads this value while the rebase stands, and two | ||||||||||||||||||||||||||||||||||||||||||
| 399 | # equal values then tell that no skip ran. | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | sub _pending ( $app, $dir ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pending: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $out = | |||||||||||||||||||||||||||||||||||||||||
| 403 | $app->command( [ 'git', 'rev-parse', 'REBASE_HEAD' ], cwd => $dir ); | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | return unless defined $out; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | chomp $out; | |||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | # _shape($app, $dir): | ||||||||||||||||||||||||||||||||||||||||||
| 411 | # The page of the race, and the reason of a refusal, in that | ||||||||||||||||||||||||||||||||||||||||||
| 412 | # order. The page is defined for a pending commit of the shape | ||||||||||||||||||||||||||||||||||||||||||
| 413 | # that --fix takes, and the reason is defined for every other | ||||||||||||||||||||||||||||||||||||||||||
| 414 | # commit. | ||||||||||||||||||||||||||||||||||||||||||
| 415 | # | ||||||||||||||||||||||||||||||||||||||||||
| 416 | # The shape has three parts (CLI-DOCTOR-2). The commit adds one | ||||||||||||||||||||||||||||||||||||||||||
| 417 | # file, the file is a session page, and the page holds no | ||||||||||||||||||||||||||||||||||||||||||
| 418 | # observation. Two sessions of one day take one page name, and | ||||||||||||||||||||||||||||||||||||||||||
| 419 | # each one pushes a header alone. The commit that loses the race | ||||||||||||||||||||||||||||||||||||||||||
| 420 | # carries no work, so the skip destroys nothing. | ||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | sub _shape ( $app, $dir ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shape: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | { | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $files = _files( $app, $dir ); | |||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | return ( undef, 'cannot read the pending commit: ' . $app->error ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | unless $files; | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | unless ( @$files == 1 && $files->[0][0] eq 'A' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@$files == 1 and $files->[0][0] eq "A"
MC/DC0%0/2
@$files == 1 and $files->[0][0] eq "A"
@$files == 1
$files->[0][0] eq "A"
Truth table0%0/3
A and B
A= @$files == 1B= $files->[0][0] eq "A"
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my @paths = map { $_->[1] } @$files; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | my $list = @paths ? join ', ', @paths : 'no file'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | return ( undef, "the pending commit changes $list" ); | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $page = $files->[0][1]; | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | return ( undef, "$page is no session page" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | unless App::FuguBench::Wiki->session_page($page); | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $text = | |||||||||||||||||||||||||||||||||||||||||
| 438 | $app->command( [ 'git', 'show', "REBASE_HEAD:$page" ], | ||||||||||||||||||||||||||||||||||||||||||
| 439 | cwd => $dir ); | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | return ( undef, "cannot read $page: " . $app->error ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my $body = App::FuguBench::Wiki->observations($text); | |||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | return ( undef, "$page holds no observation heading" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | unless defined $body; | ||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | return ( undef, "$page holds an observation" ) if $body =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | return $page; | |||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | # _files($app, $dir): | ||||||||||||||||||||||||||||||||||||||||||
| 452 | # The status and the path of each file of the pending commit, | ||||||||||||||||||||||||||||||||||||||||||
| 453 | # as a reference to a list of pairs. REBASE_HEAD names that | ||||||||||||||||||||||||||||||||||||||||||
| 454 | # commit, and it resolves while the rebase stands. | ||||||||||||||||||||||||||||||||||||||||||
| 455 | # | ||||||||||||||||||||||||||||||||||||||||||
| 456 | # A failed call gives undef, and the caller then reports the | ||||||||||||||||||||||||||||||||||||||||||
| 457 | # reason of git. A commit that changes no file gives a list of | ||||||||||||||||||||||||||||||||||||||||||
| 458 | # no pair, and the two states read apart. | ||||||||||||||||||||||||||||||||||||||||||
| 459 | # | ||||||||||||||||||||||||||||||||||||||||||
| 460 | # A rename carries two paths in one line, and the split of two | ||||||||||||||||||||||||||||||||||||||||||
| 461 | # fields keeps both. That status is no A, so the fix refuses the | ||||||||||||||||||||||||||||||||||||||||||
| 462 | # commit either way. | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | sub _files ( $app, $dir ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_files: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | { | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my $out = $app->command( | |||||||||||||||||||||||||||||||||||||||||
| 466 | [ 'git', 'show', '--name-status', '--format=', 'REBASE_HEAD' ], | ||||||||||||||||||||||||||||||||||||||||||
| 467 | cwd => $dir | ||||||||||||||||||||||||||||||||||||||||||
| 468 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | return unless defined $out; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my @files; | |||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | for my $line ( split /\n/, $out ) { | |||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my ( $status, $path ) = split /\t/, $line, 2; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | next unless defined $path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | push @files, [ $status, $path ]; | |||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | return \@files; | |||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 117 | 1; | |||||||||||||||||||||||||||||||||||||||||