=cut
use Git::PurePerl;
-
+use Path::Class qw/dir/;
sub build_per_context_instance {
my ( $self, $c ) = @_;
);
# This is fugly as fuck. Move Git::PurePerl construction into attribute builders..
- (my $pd = $self->project_dir( $self->project )) =~ s{/\.git$}();
- $model->gpp( Git::PurePerl->new(directory => $pd) );
+ my ($pd, $gd) = $model->project_dir( $model->project )->resolve =~ m{((.+?)(:?/\/\.git)?$)};
+ $gd .= '/.git' if ($gd !~ /\.git$/ and -d "$gd/.git");
+ $model->gpp( Git::PurePerl->new(gitdir => $gd, directory => $pd) );
return $model;
}
sub parse_rev_list {
my ($self, $output) = @_;
- my @ret;
-
- my @revs = split /\0/, $output;
- for my $rev (split /\0/, $output) {
- for my $line (split /\n/, $rev, 6) {
- chomp $line;
- next unless $line;
-
- if ($self->valid_rev($line)) {
- push @ret, $self->get_object($line);
- }
- }
- }
-
- return @ret;
+ return
+ map $self->get_object($_),
+ grep $self->valid_rev($_),
+ map split(/\n/, $_, 6), split /\0/, $output;
}
=head2 list_revs
sub list_revs {
my ($self, %args) = @_;
- $args{sha1} ||= $self->head_hash($args{project});
+ $args{sha1} = $self->head_hash($args{sha1})
+ if !$args{sha1} || $args{sha1} !~ $SHA1RE;
+
+ my @search_opts;
+ if($args{search}) {
+ my $sargs = $args{search};
+ $sargs->{type} = 'grep'
+ if $sargs->{type} eq 'commit';
+ @search_opts = (
+ # This seems a little fragile ...
+ qq[--$sargs->{type}=$sargs->{text}],
+ '--regexp-ignore-case',
+ $sargs->{regexp} ? '--extended-regexp' : '--fixed-strings'
+ );
+ }
my $output = $self->run_cmd_in($args{project} || $self->project, 'rev-list',
'--header',
- (defined $args{ count } ? "--max-count=$args{count}" : ()),
- (defined $args{ skip } ? "--skip=$args{skip}" : ()),
+ (defined $args{ count } ? "--max-count=$args{count}" : ()),
+ (defined $args{ skip } ? "--skip=$args{skip}" : ()),
+ @search_opts,
$args{sha1},
'--',
($args{file} ? $args{file} : ()),