use MooseX::Types::Path::Class qw/Dir/;
use MooseX::Types::Moose qw/Str Maybe Bool HashRef ArrayRef/;
use Gitalist::Git::Types qw/SHA1/;
+ use MooseX::MultiMethods;
use Moose::Autobox;
use List::MoreUtils qw/any zip/;
use DateTime;
use Encode qw/decode/;
-# use I18N::Langinfo qw/langinfo CODESET/;
+ use I18N::Langinfo qw/langinfo CODESET/;
use Gitalist::Git::Object::Blob;
use Gitalist::Git::Object::Tree;
use Gitalist::Git::Object::Commit;
}
## 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;
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) {
$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;
}
method _build_owner {
- # XXX No I18N::Langinfo & getpwuid make win32 sad :(
- # my ($gecos, $name) = map { decode(langinfo(CODESET), $_) } (getpwuid $self->path->stat->uid)[6,0];
- my ($gecos, $name) = do {
- local $@;
- my($g,$n) = eval { (getpwuid $self->path->stat->uid)[6,0] };
- !$@ ? ($g,$n) : qw(OwenEr GroUp);
- };
+ my ($gecos, $name) = map { decode(langinfo(CODESET), $_) } (getpwuid $self->path->stat->uid)[6,0];
$gecos =~ s/,+$//;
return length($gecos) ? $gecos : $name;
}