X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FGitalist%2FGit%2FRepository.pm;h=e4eb595f036734d9c2c23fc50b11dbf2501db90a;hb=68943a848e5fae4bd91569b930ddcdcecc6dfe9b;hp=a230129c644432cb9bfa1f6672fe8300c2381926;hpb=68b525fcc3c5788eef526ebb643746317a10372b;p=catagits%2FGitalist.git diff --git a/lib/Gitalist/Git/Repository.pm b/lib/Gitalist/Git/Repository.pm index a230129..e4eb595 100644 --- a/lib/Gitalist/Git/Repository.pm +++ b/lib/Gitalist/Git/Repository.pm @@ -4,6 +4,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils { # FIXME, use Types::Path::Class and coerce use MooseX::Types::Common::String qw/NonEmptySimpleStr/; use MooseX::Types::Moose qw/Str Maybe Bool HashRef ArrayRef/; + use MooseX::MultiMethods; use Gitalist::Git::Types qw/SHA1 DateTime Dir/; use Moose::Autobox; use List::MoreUtils qw/any zip/; @@ -78,6 +79,15 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils { } ## Public methods + + multi method get_object_or_head (SHA1 $sha1) { + $self->get_object($sha1); + } + multi method get_object_or_head (NonEmptySimpleStr $ref) { + my $sha1 = $self->head_hash($ref); + $self->get_object($sha1); + } + method head_hash (Str $head?) { my $output = $self->run_cmd(qw/rev-parse --verify/, $head || 'HEAD' ); confess("No such head: " . $head) unless defined $output; @@ -129,7 +139,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils { if !$sha1 || $sha1 !~ $SHA1RE; my @search_opts; - if ($search) { + if ($search and exists $search->{text}) { $search->{type} = 'grep' if $search->{type} eq 'commit'; @search_opts = ( @@ -180,11 +190,11 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils { method diff ( Gitalist::Git::Object :$commit!, Bool :$patch?, Maybe[NonEmptySimpleStr] :$parent?, - NonEmptySimpleStr :$file? + NonEmptySimpleStr :$filename? ) { return $commit->diff( patch => $patch, parent => $parent, - file => $file); + filename => $filename); } method reflog (@logargs) { @@ -241,6 +251,8 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils { $description = $self->path->file('description')->slurp; chomp $description; }; + $description = "Unnamed repository, edit the .git/description file to set a description" + if $description eq "Unnamed repository; edit this file 'description' to name the repository."; return $description; }