App-Gitc

 view release on metacpan or  search on metacpan

lib/App/Gitc/Util.pm  view on Meta::CPAN

        its_for_changeset
    );
    our @EXPORT_OK = qw(
        add_current_user
        archived_tags
        branch_basis
        branch_point
        cache_meta_data
        changeset_group
        changeset_merged_to
        changesets_in
        changesets_promoted_between
        command_name
        commit_decorations
        confirm
        current_branch_version
        environment_preceding
        full_changeset_name
        git_fetch_and_clean_up
        git_dir
        git_tag
        highest_quickfix_number
        history
        history_owner
        history_reviewer
        history_status
        history_submitter
        is_auto_fetch
        is_merge_commit
        is_suspendable
        is_valid_ref
        meta_data_rm_project
        new_branch_version
        new_version_tag
        open_packed_refs
        parse_changeset_spec
        project_name
        project_root
        remote_branch_exists
        restore_meta_data
        sendmail
        short_ref_name
        sort_changesets_by_name
        toplevel
        traverse_commits
        unmerged_changesets
        unpromoted
        user_lookup_class
        version_tag_prefix
        state_blocked
    );
}


sub confirm {
    my ($message) = @_;
    die "No message given to 'confirm'" if not defined $message;

    require Term::ReadLine;
    my $term   = Term::ReadLine->new('gitc');
    my $prompt = "$message ";
    my $response;

    # prompt the user
    while ( defined( $response = $term->readline($prompt) ) ) {
        return 1 if $response eq 'y';
        return   if $response eq 'n';
        $prompt = "$message ('y' or 'n') ";
    }
}


# If this ever needs to be faster, it can be implemented by opening
# .git/HEAD and parsing the one line contents.  It would take a bit
# more effort to get it right, but it would avoid the fork+exec overhead
sub current_branch {
    my ($name) = grep /^[*]/, qx{ git branch --no-color };
    chomp $name;
    $name =~ s/^[*] //;
    return $name;
}


sub its_config {
    my $name = lc its()->label_service;

    return project_config()->{ "${name}_statuses" };
}

# Eventum is the name of our internal ticketing system.
sub eventum {
    return its()->get_issue( @_ );
}

sub eventum_transition_status {
    return its()->transition_state( @_ );
}


sub eventum_statuses {
    my ( $self, $command, $target ) = @_;

    my $statuses = project_config()->{'jira_statuses'}{$command}
        or die "No JIRA statuses for $command";

    # handle the common case
    if ( not $target ) {
        die "No initial status" unless $statuses->{from};
        die "No final status" unless $statuses->{to};
        return ( $statuses );
    }

    # promotions need another level of dereference
        die "No initial status for target $target" unless $statuses->{$target}{from};
        die "No final status for target $target" unless $statuses->{$target}{to};
        return $statuses->{$target};

}


sub _package_its {
    my $its_type = shift;

    return 'App::Gitc::Its::'.ucfirst $its_type; 
}

sub its {
    my $its = shift || project_config()->{'default_its'};



( run in 1.537 second using v1.01-cache-2.11-cpan-6aa56a78535 )