App-Critique
view release on metacpan or search on metacpan
lib/App/Critique/Command.pm view on Meta::CPAN
sub opt_spec {
my ( $class, $app ) = @_;
return (
[ 'git-work-tree=s', 'git working tree, defaults to current working directory', { default => Path::Tiny->cwd } ],
[],
[ 'debug|d', 'display debugging information', { default => $App::Critique::CONFIG{'DEBUG'}, implies => 'verbose' } ],
[ 'verbose|v', 'display additional information', { default => $App::Critique::CONFIG{'VERBOSE'} } ],
);
}
sub validate_args {
my ($self, $opt, $args) = @_;
$self->usage_error('The git-work-tree does not exist (' . $opt->git_work_tree . ')')
unless -d $opt->git_work_tree;
}
sub cautiously_load_session {
my ($self, $opt, $args) = @_;
if ( my $session_file_path = App::Critique::Session->locate_session_file( $opt->git_work_tree ) ) {
lib/App/Critique/Command/tutorial.pm view on Meta::CPAN
use strict;
use warnings;
our $VERSION = '0.05';
our $AUTHORITY = 'cpan:STEVAN';
use App::Critique -command;
sub opt_spec { return ([]) }
sub validate_args { 1 }
sub execute { info( $_[0]->description ) }
1;
=pod
=head1 NAME
App::Critique::Command::tutorial - Tutorial about how to use critique
lib/App/Critique/Session.pm view on Meta::CPAN
);
}
## ...
sub _initialize_git_repo {
my ($class, %args) = @_;
my $git = Git::Wrapper->new( $args{git_work_tree} );
# auto-discover/validate the current git branch
my ($git_branch) = map /^\*\s(.*)$/, grep /^\*/, $git->branch;
Carp::confess('Unable to determine git branch, looks like your repository is bare')
unless $git_branch;
# make sure the branch we are on is the
# same one we are being asked to load,
# this error condition is very unlikely
# to occur since the session file path
# is based on branch, which is dynamically
# determined on load. The only way this
# could happen is if you manually loaded
# the session file for one branch while
# intentionally on another branch. So while
# this is unlikely, it is probably something
# we should die about none the less since
# it might be a real pain to debug.
Carp::confess('Attempting to inflate session for branch ('.$args{git_branch}.') but branch ('.$git_branch.') is currently active')
if exists $args{git_branch} && $args{git_branch} ne $git_branch;
# auto-discover/validate the git HEAD sha
my $git_head_sha = $args{git_head_sha};
# if we have it already, ...
if ( $git_head_sha ) {
# test to make sure the SHA is an ancestor
my ($possible_branch) = map /^\*\s(.*)$/, grep /^\*/, $git->branch({
contains => $git_head_sha
});
( run in 0.502 second using v1.01-cache-2.11-cpan-4d50c553e7e )