diff options
Diffstat (limited to 'libpiny/lib/Piny/Repo.pm')
-rw-r--r-- | libpiny/lib/Piny/Repo.pm | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm index 8a26563..5b075a1 100644 --- a/libpiny/lib/Piny/Repo.pm +++ b/libpiny/lib/Piny/Repo.pm @@ -11,6 +11,7 @@ use Moose::Util::TypeConstraints; use MooseX::StrictConstructor; use Digest::SHA qw( sha256_hex ); +use File::Copy; use File::Find qw( find ); use File::Temp qw( ); use IO::Dir qw( ); @@ -456,10 +457,10 @@ sub all_repos { # Only sets up needed data; ->rebuild takes care of the rest. sub create { - my ( $class, $name, $description, $source ) = @_; + my ( $class, $name, $description, $remote ) = @_; - if ( not defined $source) { - $source = Piny::Config->new->piny_template; + if ( not defined $remote) { + $remote = Piny::Config->new->piny_template; }; my $user = Piny::Environment->instance->user; @@ -472,11 +473,17 @@ sub create { mkdir( $repo->path ) or die "The repo $name appears to already exist! ($!)"; chdir( "/srv/git" ); # so git-clone can do the work of resolving local repo names for us - if ( defined $source ) { + if ( defined $remote ) { system( "/bin/chown", $user->name, $repo->path ) and die "Could not change ownership of repo path!"; # permissions are overridden later - if ( system( "/usr/bin/sudo", "-u", $user->name, "/usr/bin/git", "clone", "--bare", "--no-hardlinks", "--quiet", $source, $repo->path ) ) { # sudo -u $user needed in order to test user readability of whatever they want to clone. the mode o+rx should probably be masked off if we want private repos to stay private. + if ( system( "/usr/bin/sudo", "-u", $user->name, "/usr/bin/git", "clone", "--bare", "--no-hardlinks", "--quiet", $remote, $repo->path ) ) { # sudo -u $user needed in order to test user readability of whatever they want to clone. the mode o+rx should probably be masked off if we want private repos to stay private. system( "/bin/rm", "-r", $repo->path ) and die "Failed to clean up after failed clone operation!"; die( "Could not clone repository!\n" ); + } else { + if( Piny::Repo->new( $remote ) ) { + copy( $remote . ".git/config", $repo->path . "config" ) or die "Config copy failed: $!"; + } else { + print( "$remote is not local, unable to copy config file."); + } }; } else { system( "/usr/bin/git", "init", "--bare", "--quiet", $repo->path ) and die "Could not initialize git repo!"; |