Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Axel 'fREW' Schmidt committed Apr 20, 2014
1 parent 7b11256 commit fd64445
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 31 deletions.
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ requires 'Config::GitLike';
requires 'Data::Stream::Bulk';
requires 'DateTime';
requires 'File::Find::Rule';
requires 'IO::All';
requires 'IO::Digest';
requires 'Moo';
requires 'MooX::Types::MooseLike';
Expand Down
33 changes: 14 additions & 19 deletions lib/Cogit.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@ use Cogit::Pack::WithIndex;
use Cogit::Pack::WithoutIndex;
use Cogit::Protocol;
use Path::Class;
use IO::All;
use namespace::clean;

has directory => (
is => 'ro',
isa => InstanceOf['Path::Class::Dir'],
coerce => sub { return dir($_[0]); },
);
has directory => ( is => 'ro' );

has gitdir => (
is => 'ro',
isa => InstanceOf['Path::Class::Dir'],
coerce => sub { return dir($_[0]); },
required => 1,
);

Expand Down Expand Up @@ -157,7 +152,7 @@ sub ref_sha1 {

if ($wantref eq "HEAD") {
my $file = file($self->gitdir, 'HEAD');
my $sha1 = file($file)->slurp
my $sha1 = io->file($file)->slurp
|| confess("Error reading $file: $!");
chomp $sha1;
return _ensure_sha1_is_sha1( $self, $sha1 );
Expand All @@ -166,7 +161,7 @@ sub ref_sha1 {
foreach my $file ( File::Find::Rule->new->file->in($dir) ) {
my $ref = 'refs/' . file($file)->relative($dir)->as_foreign('Unix');
if ( $ref eq $wantref ) {
my $sha1 = file($file)->slurp
my $sha1 = io->file($file)->slurp
|| confess("Error reading $file: $!");
chomp $sha1;
return _ensure_sha1_is_sha1( $self, $sha1 );
Expand Down Expand Up @@ -296,7 +291,7 @@ sub create_object {

sub all_sha1s {
my $self = shift;
my $dir = dir( $self->gitdir, 'objects' );
my $dir = io->dir( $self->gitdir, 'objects' );

my @streams;
push @streams, $self->loose->all_sha1s;
Expand Down Expand Up @@ -355,15 +350,15 @@ sub init {
if ( not defined $arguments{gitdir} ) {
$git_dir = $arguments{gitdir} = dir( $directory, '.git' );
}
dir($directory)->mkpath;
io->dir($directory)->mkpath;
}

dir($git_dir)->mkpath;
dir( $git_dir, 'refs', 'tags' )->mkpath;
dir( $git_dir, 'objects', 'info' )->mkpath;
dir( $git_dir, 'objects', 'pack' )->mkpath;
dir( $git_dir, 'branches' )->mkpath;
dir( $git_dir, 'hooks' )->mkpath;
io->dir($git_dir)->mkpath;
io->dir( $git_dir, 'refs', 'tags' )->mkpath;
io->dir( $git_dir, 'objects', 'info' )->mkpath;
io->dir( $git_dir, 'objects', 'pack' )->mkpath;
io->dir( $git_dir, 'branches' )->mkpath;
io->dir( $git_dir, 'hooks' )->mkpath;

my $bare = defined($directory) ? 'false' : 'true';
$class->_add_file(
Expand Down Expand Up @@ -395,7 +390,7 @@ sub init {
$class->_add_file( file( $git_dir, 'hooks', 'update' ),
"# add shell script and make executable to enable\n" );

dir( $git_dir, 'info' )->mkpath;
io->dir( $git_dir, 'info' )->mkpath;
$class->_add_file( file( $git_dir, 'info', 'exclude' ),
"# *.[oa]\n# *~\n" );

Expand All @@ -417,7 +412,7 @@ sub checkout {
chmod( oct( '0' . $mode ), $filename )
|| die "Error chmoding $filename to $mode: $!";
} elsif ( $object->kind eq 'tree' ) {
dir($filename)->mkpath;
io->dir($filename)->mkpath;
$self->checkout( $filename, $object );
} else {
die $object->kind;
Expand Down
3 changes: 2 additions & 1 deletion lib/Cogit/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package Cogit::Config;

use Moo;
use MooX::Types::MooseLike::Base qw( InstanceOf );
use Path::Class;
use namespace::clean;

extends 'Config::GitLike';
Expand All @@ -17,7 +18,7 @@ has git => (

sub dir_file {
my $self = shift;
return $self->git->gitdir->file("config");
return dir($self->git->gitdir)->file("config");
};

1;
2 changes: 0 additions & 2 deletions lib/Cogit/Loose.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use namespace::clean;

has directory => (
is => 'ro',
isa => InstanceOf['Path::Class::Dir'],
required => 1,
coerce => sub { dir($_[0]) if !obj($_[0], 'Path::Class::Dir'); $_[0]; },
);

sub get_object {
Expand Down
3 changes: 0 additions & 3 deletions lib/Cogit/Pack.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package Cogit::Pack;

use Moo;
use MooX::Types::MooseLike::Base 'InstanceOf';
use Path::Class;
use Compress::Raw::Zlib;
use IO::File;
use Carp 'confess';
Expand All @@ -11,9 +10,7 @@ use namespace::clean;

has filename => (
is => 'ro',
isa => InstanceOf['Path::Class::File'],
required => 1,
coerce => sub { file($_[0]) if !obj($_[0], 'Path::Class::File'); $_[0]; },
);

has fh => (
Expand Down
3 changes: 0 additions & 3 deletions lib/Cogit/Pack/WithIndex.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ use Moo;
use Cogit::PackIndex::Version1;
use Cogit::PackIndex::Version2;
use MooX::Types::MooseLike::Base 'InstanceOf';
use Path::Class;
use Check::ISA;
use namespace::clean;

extends 'Cogit::Pack';

has index_filename => (
is => 'rw',
coerce => sub { file($_[0]) if !obj($_[0], 'Path::Class::File'); $_[0]; },
#isa => InstanceOf['Path::Class::File'],
);

has index => (
Expand Down
3 changes: 0 additions & 3 deletions lib/Cogit/PackIndex.pm
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package Cogit::PackIndex;

use Moo;
use Path::Class 'file';
use Check::ISA;
use IO::File;
use MooX::Types::MooseLike::Base qw( InstanceOf ArrayRef Str Int );
use namespace::clean;

has filename => (
is => 'ro',
isa => InstanceOf['Path::Class::File'],
coerce => sub { file($_[0]) },
required => 1,
);

Expand Down

0 comments on commit fd64445

Please sign in to comment.