3 class Gitalist::Git::Util {
6 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
8 isa => 'Gitalist::Git::Project',
9 handles => { gitdir => 'path' },
10 is => 'bare', # No accessor
11 weak_ref => 1, # Weak, you have to hold onto me.
12 predicate => 'has_project',
14 has _git => ( isa => NonEmptySimpleStr, is => 'ro', lazy_build => 1 );
16 my $git = File::Which::which('git');
20 Could not find a git executable.
21 Please specify the which git executable to use in gitweb.yml
29 isa => 'Git::PurePerl', is => 'ro', lazy => 1,
32 confess("Cannot get gpp without project")
33 unless $self->has_project;
34 Git::PurePerl->new(gitdir => $self->gitdir);
38 method run_cmd (@args) {
39 unshift @args, ( '--git-dir' => $self->gitdir )
40 if $self->has_project;
41 # print STDERR 'RUNNING: ', $self->_git, qq[ @args], $/;
43 open my $fh, '-|', $self->_git, @args
44 or die "failed to run git command";
45 binmode $fh, ':encoding(UTF-8)';
47 my $output = do { local $/ = undef; <$fh> };
53 method get_gpp_object (NonEmptySimpleStr $sha1) {
54 return $self->_gpp->get_object($sha1) || undef;