X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FGitalist%2FModel%2FGit.pm;h=02339810b60f101d1c192c3172595438b957c6fd;hb=c8870bd37732961cdb6c22994839c8b43c33cc7a;hp=abc212b9943f03d1afc1f025a4c8769d0f06ee6c;hpb=b3ad9e63b0e079a3e7599734ccd6244ca5921601;p=catagits%2FGitalist.git diff --git a/lib/Gitalist/Model/Git.pm b/lib/Gitalist/Model/Git.pm index abc212b..0233981 100644 --- a/lib/Gitalist/Model/Git.pm +++ b/lib/Gitalist/Model/Git.pm @@ -187,10 +187,10 @@ sub git_dir_from_project_name { return dir($self->repo_dir)->subdir($project); } -sub get_head_hash { +sub head_hash { my ($self, $project) = @_; - my $output = $self->run_cmd_in($self->project, qw/rev-parse --verify HEAD/ ); + my $output = $self->run_cmd_in($project || $self->project, qw/rev-parse --verify HEAD/ ); return unless defined $output; my ($head) = $output =~ /^($SHA1RE)$/; @@ -200,7 +200,7 @@ sub get_head_hash { sub list_tree { my ($self, $project, $rev) = @_; - $rev ||= $self->get_head_hash($project); + $rev ||= $self->head_hash($project); my $output = $self->run_cmd_in($project, qw/ls-tree -z/, $rev); return unless defined $output; @@ -237,19 +237,19 @@ sub get_object_type { return $output; } -sub get_hash_by_path { +sub hash_by_path { my($self, $base, $path, $type) = @_; $path =~ s{/+$}(); - my $line = $self->run_cmd_in($self->project, 'ls-tree', $base, '--', $path) + my($line) = $self->command('ls-tree', $base, '--', $path) or return; #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c' $line =~ m/^([0-9]+) (.+) ($SHA1RE)\t/; return defined $type && $type ne $2 ? () - : return $3; + : $3; } sub cat_file { @@ -341,7 +341,7 @@ sub diff { sub list_revs { my ($self, $project, %args) = @_; - $args{rev} ||= $self->get_head_hash($project); + $args{rev} ||= $self->head_hash($project); my $output = $self->run_cmd_in($project, 'rev-list', '--header', @@ -509,7 +509,7 @@ sub diff_tree { my %line = zip @keys, @vals; # Some convenience keys $line{file} = $line{src}; - $line{sha1} = $line{sha1src}; + $line{sha1} = $line{sha1dst}; $line{is_new} = $line{sha1src} =~ /^0+$/; \%line; } @dtout;