The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::GHPT::WorkSubmitter::Question::ExampleFileNameCheck - An example supplemental question for pull requests

VERSION

version 1.000009

SYNOPSIS

    package App::GHPT::WorkSubmitter::Question::ExampleFileNameCheck;

    use App::GHPT::Wrapper::OurMoose;

    with('App::GHPT::WorkSubmitter::Role::Question');

    sub ask ($self) {
        my @answers;

        # must return an array of text to insert in the pull request description
        for my $file (
            'should/not/be/changed',
            'do/not/touch',
            'abandon/hope/all/who/edit/this/file',
            'badfile',
            ) {
            next unless $self->changed_files->file_exists($file);

            # if our class had consumed the
            # App::GHPT::WorkSubmitter::Role::FileInspector role we could
            # use $self->file_contents( $file ) to see what was in the file
            # staged for commit in the staging area (opposed to the what's in
            # the working directory which may be different) but that's slow, so
            # we're not doing that in this example

            # ask the question, provide the default answers which the user
            # can select from, or the last option which is "Launch Editor"
            # so they can give an arbitary answer
            push @answers, $self->ask_question(
                <<"ENDOFQUESTION",
    file $file really should not be changed unless you've got
    a really really really good reason.

    What's your reason?
    ENDOFQUESTION
                    q{No good reason, but PHB told me to do this so here we are},
                    q{I have my reasons, but I can't tell them to you},
                );
            }

        return @answers;
    }

    __PACKAGE__->meta->make_immutable;

    1;

DESCRIPTION

If you create one or more modules under the App::GHPT::WorkSubmitter::Question namespace, these modules will be loaded and used to (maybe) ask additional questions as part of creating a pull request.

This is useful if you want to automate prompting for various potential issues. For example, you might look for database migrations and ask the person submitting the pull request about things like table locking, whether the existing code will work with the changed schema, etc.

API

To make a question work, you must follow a certain API:

  • Consume the App::GHPT::WorkSubmitter::Role::Question role.

  • Implement the ask method required by this role. This method will be called with no arguments. Internally, it is expected to call $self->ask_question( $question, @responses ). The first argument is the question to ask, like "Have you tested this migration on the staging environment to make sure it does not degrade REST API performance?". The remaining arguments are potential responses. These responses will be offered to the person running the GHPT tool.

SUPPORT

Bugs may be submitted through https://github.com/maxmind/App-GHPT/issues.

AUTHORS

  • Mark Fowler <mark@twoshortplanks.com>

  • Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by MaxMind, Inc.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)