App/git/clean_forge_repo.pm untested

filter: Statementstmt 0.0% 0 / 52 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 8 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 82 CC 4 SCAR 19.2
CC
4
Cov
0%
main
20.0
exit
2.0
BEGIN
2.0
CRAP 6.8
1 package App::git::clean_forge_repo;
2 # ABSTRACT: create repos on git forges with optional features disabled
3 #
4 # Copyright (C) 2020 Sean Whitton <spwhitton@spwhitton.name>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or (at
9 # your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 $App::git::clean_forge_repo::VERSION = '0.005';
19 use 5.028;
20 use strict;
21 use warnings;
22  
23 use subs 'main';
24 use Cwd;
25 use Term::UI;
26 use Getopt::Long;
27 use Git::Wrapper;
28 use API::GitForge qw(new_from_domain forge_access_token remote_forge_info);
29 use Try::Tiny;
30  
31 my $exit_main = 0;
32  
33 CORE::exit main unless caller;
34  
35  
36 sub main {
37 shift if $_[0] and ref $_[0] eq "";
38 local @ARGV = @{ $_[0] } if $_[0] and ref $_[0] ne "";
39  
40 my $term = Term::ReadLine->new("brand");
41 my $remote = "origin";
42 my $git = Git::Wrapper->new(getcwd);
43 #<<<
44 try {
45 $git->rev_parse({ git_dir => 1 });
46 } catch {
47 die "pwd doesn't look like a git repository ..\n";
48 };
49 #>>>
50 GetOptions "remote=s" => \$remote;
51  
52 my ($forge_domain, $forge_repo) = remote_forge_info $remote;
53 exit
54 unless $term->ask_yn(
55 prompt => "Do you want to create repo $forge_repo?");
56  
57 my $forge = new_from_domain
58 domain => $forge_domain,
59 access_token => forge_access_token $forge_domain;
60 $forge->clean_repo($forge_repo);
61  
62 EXIT_MAIN:
63 return $exit_main;
64 }
65  
66 sub exit { $exit_main = shift // 0; goto EXIT_MAIN }
67  
68 __END__