line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use App::GHPT::Wrapper::OurMoose::Role; |
3
|
1
|
|
|
1
|
|
5689
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
4
|
|
|
|
|
|
|
our $VERSION = '2.000000'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Term::CallEditor qw( solicit ); |
7
|
1
|
|
|
1
|
|
124
|
use Term::Choose qw( choose ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
78
|
|
8
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
540
|
|
9
|
|
|
|
|
|
|
requires 'ask'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has changed_files => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
isa => 'App::GHPT::WorkSubmitter::ChangedFiles', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $choice = choose( |
18
|
0
|
|
|
0
|
1
|
|
[ |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
@responses, |
20
|
|
|
|
|
|
|
'Launch Editor' |
21
|
|
|
|
|
|
|
], |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
prompt => $question, |
24
|
|
|
|
|
|
|
clear_screen => $ENV{'SUBMIT_WORK_CLEAR'} // 0 |
25
|
|
|
|
|
|
|
} |
26
|
0
|
0
|
0
|
|
|
|
) or exit; # user hit 'q' or ctrl-d to stop |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return $self->format_qa_markdown( $question, $choice ) |
29
|
|
|
|
|
|
|
unless $choice eq 'Launch Editor'; |
30
|
0
|
0
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# todo: It would be nice if the notes persisted to disk for a given PT so |
32
|
|
|
|
|
|
|
# that I could ctrl-c out of a later question and still not have to retype |
33
|
|
|
|
|
|
|
# previously asked questions. That's a task for another day however. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $prompt = <<"ENDOFTEXT"; |
36
|
|
|
|
|
|
|
$question |
37
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Complete your answer below the line in markdown. |
39
|
|
|
|
|
|
|
--- |
40
|
|
|
|
|
|
|
ENDOFTEXT |
41
|
|
|
|
|
|
|
my $fh = solicit($prompt); |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $answer = do { local $/ = undef; <$fh> }; |
44
|
|
|
|
|
|
|
$answer =~ s/\A\Q$prompt//; |
45
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $self->format_qa_markdown( $question, $answer ); |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
50
|
|
|
|
|
|
|
return $text =~ s/\A\s+//r =~ s/\s+\z//r; |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
0
|
|
|
## use critic |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return <<"ENDOFMARKDOWN"; |
55
|
|
|
|
|
|
|
### Question ### |
56
|
|
|
|
|
|
|
@{[ _trim( $question )]} |
57
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
### Answer ### |
59
|
|
|
|
|
|
|
@{[ _trim( $answer ) ]} |
60
|
0
|
|
|
|
|
|
ENDOFMARKDOWN |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# ABSTRACT: Role for writing interactive questions about the commits |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=encoding UTF-8 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
App::GHPT::WorkSubmitter::Role::Question - Role for writing interactive questions about the commits |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 VERSION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
version 2.000000 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SYNOPSIS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package App::GHPT::WorkSubitter::Question::WarnAboutPasswordFile; |
83
|
|
|
|
|
|
|
use App::GHPT::Wrapper::OurMoose; |
84
|
|
|
|
|
|
|
with 'App::GHPT::WorkSubmitter::Role::Question'; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub ask($self) { |
87
|
|
|
|
|
|
|
# skip the question unless there's a password file |
88
|
|
|
|
|
|
|
return unless $self->changed_files->changed_files_match(qr/password/); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# ask the user if that's okay |
91
|
|
|
|
|
|
|
return $self->ask_question(<<'ENDOFTEXT',"I'm okay with the risk"); |
92
|
|
|
|
|
|
|
You've committed a file with a name matching 'password'. Are you nuts? |
93
|
|
|
|
|
|
|
ENDOFTEXT |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This role allows you to write questions to ask someone when creating pull |
102
|
|
|
|
|
|
|
request. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
You want to create these questions classes in the |
105
|
|
|
|
|
|
|
C<App::GHPT::WorkSubmitter::Question::*> namespace where |
106
|
|
|
|
|
|
|
L<App::GHPT::WorkSubmitter::Questioner> will automatically detect them and ask |
107
|
|
|
|
|
|
|
them each time C<gh-pt.pl> is run. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Each class must supply an C<ask> method which should prompt the user as needed |
110
|
|
|
|
|
|
|
and return any markdown to be placed in the pull request body. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 changed_files |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
The files that have changed in this branch. This is the primary attribute |
117
|
|
|
|
|
|
|
you want to examine. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 METHODS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 $question->ask_question($question, @optional_responses) |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Interactively ask a question and return markdown suitable for including in the |
124
|
|
|
|
|
|
|
pull request body. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The question that should be asked must be passed as the first argument, and |
127
|
|
|
|
|
|
|
all other arguments are treated as stock answers the user can select when |
128
|
|
|
|
|
|
|
asked the question. The user will also have a final option C<Launch Editor> |
129
|
|
|
|
|
|
|
which will launch their editor and allow them free-form text input. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SUPPORT |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/App-GHPT/issues>. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 AUTHORS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over 4 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Mark Fowler <mark@twoshortplanks.com> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by MaxMind, Inc. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This is free software, licensed under: |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |