App-GHPT

 view release on metacpan or  search on metacpan

lib/App/GHPT/WorkSubmitter.pm  view on Meta::CPAN


    return $memberships[0]->person if @memberships == 1;

    my %membership_by_person_name
        = map { $_->person->name => $_ } @memberships;
    my $name = $self->_choose( [ sort keys %membership_by_person_name ] );
    return $membership_by_person_name{$name}->person;
}

before print_usage_text => sub {
    say <<'EOF';
Please see POD in App::GHPT for installation and troubleshooting directions.
EOF
};

sub run ($self) {
    my ( $requester, $chosen_story ) = $self->_choose_pt_story;
    unless ($requester) {
        die "No requester found!\n";
    }
    unless ($chosen_story) {

lib/App/GHPT/WorkSubmitter.pm  view on Meta::CPAN

    }

    my $pull_request_url = $self->_create_pull_request(
        $self->_append_question_answers(
            $self->_confirm_story(
                $self->_text_for_story( $chosen_story, $requester ),
            ),
        ),
    );
    $self->_update_pt_story( $chosen_story, $pull_request_url );
    say $chosen_story->url;
    say $pull_request_url;

    return 0;
}

sub _append_question_answers ( $self, $text ) {
    my $qa_markdown = App::GHPT::WorkSubmitter::AskPullRequestQuestions->new(
        merge_to_branch_name => 'origin/' . $self->base,
        question_namespaces  => $self->_question_namespaces,
    )->ask_questions;
    return $text unless defined $qa_markdown and length $qa_markdown;

lib/App/GHPT/WorkSubmitter.pm  view on Meta::CPAN

        || exit 1;    # user hit q or ctrl-d to quit
}

sub _choose_pt_story ($self) {
    if ( $self->create_story ) {
        my $project   = $self->_find_project;
        my $requester = $self->_find_requester($project);
        my $name      = $self->_get_story_name;

        if ( $self->dry_run ) {
            say "Would create story $name in "
                . $project->name
                . ' with requester '
                . $requester->name
                . ' but this is a dry-run.';
            exit;
        }

        return (
            $requester->name,
            $self->_pt_api->create_story(

lib/App/GHPT/WorkSubmitter.pm  view on Meta::CPAN


    return (
        $stories_lookup{$chosen_story}->requested_by->name,
        $stories_lookup{$chosen_story}
    );
}

sub _get_story_name ($self) {
    my $story_name = $self->story_name;
    if ( !$story_name ) {
        say q{Please enter the new story's name:};
        $story_name = $self->_read_line;
    }
    return $story_name;
}

sub _read_line ($) {
    while (1) {
        my $l = readline( \*STDIN );
        $l =~ s/^\s+|\s+$//g;
        return $l if $l;
    }
}

sub _filter_chores_and_maybe_warn_user ( $self, $stories ) {
    my ( $chore_stories, $non_chore_stories )
        = part { $_->story_type eq 'chore' ? 0 : 1 } $stories->@*;

    say 'Note: '
        . ( scalar $chore_stories->@* )
        . PL( ' chore', scalar $chore_stories->@* )
        . PL_V( ' is', scalar $chore_stories->@* )
        . ' not shown here (chores by definition do not require review).'
        if $chore_stories;

    return $non_chore_stories // [];
}

sub _confirm_story ( $self, $text ) {

lib/App/GHPT/WorkSubmitter/ChangedFiles.pm  view on Meta::CPAN


=for test_synopsis use v5.20;

    my $factory = App::GHPT::WorkSubmitter::ChangedFilesFactory->new(
        merge_to_branch_name => 'main',
    );

    my $changed_files = $factory->changed_files;

    # print out all modified / added file in this branch
    say for $changed_files->changed_files->@*;

=head1 ATTRIBUTES

=head2 added_files

All files added in this branch.

Arrayref of String. Required.

=head2 modified_files

lib/App/GHPT/WorkSubmitter/ChangedFilesFactory.pm  view on Meta::CPAN

Used by L<App::GHPT::WorkSubmitter::AskPullRequestQuestions>.

=for test_synopsis use v5.20;

  my $factory = App::GHPT::WorkSubmitter::ChangedFilesFactory->new(
      merge_to_branch_name => 'main',
  );

  my $changed_files = $factory->changed_files;

  say 'The files that were added or modified since branching are:';
  say for $changed_files->changed_files;

=head1 SUPPORT

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

=head1 AUTHORS

=over 4

=item *



( run in 0.422 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )