3 class Gitalist::Git::Util {
7 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
10 isa => 'Gitalist::Git::Project',
11 handles => { gitdir => 'path' },
12 is => 'bare', # No accessor
13 weak_ref => 1, # Weak, you have to hold onto me.
14 predicate => 'has_project',
16 has _git => ( isa => NonEmptySimpleStr, is => 'ro', lazy_build => 1 );
18 my $git = File::Which::which('git');
22 Could not find a git executable.
23 Please specify the which git executable to use in gitweb.yml
31 isa => 'Git::PurePerl', is => 'ro', lazy => 1,
34 confess("Cannot get gpp without project")
35 unless $self->has_project;
36 Git::PurePerl->new(gitdir => $self->gitdir);
40 method run_cmd (@args) {
41 unshift @args, ( '--git-dir' => $self->gitdir )
42 if $self->has_project;
43 # print STDERR 'RUNNING: ', $self->_git, qq[ @args], $/;
44 run [$self->_git, @args], \my($in, $out, $err);
49 method run_cmd_fh (@args) {
50 unshift @args, ('--git-dir' => $self->gitdir)
51 if $self->has_project;
52 run [$self->_git, @args],
56 or die "cmd returned *?";
60 method run_cmd_list (@args) {
61 my $cmdout = $self->run_cmd(@args);
62 return $cmdout ? split(/\n/, $cmdout) : ();
65 method get_gpp_object (NonEmptySimpleStr $sha1) {
66 return $self->gpp->get_object($sha1) || undef;