summaryrefslogtreecommitdiff
path: root/libpiny/lib/Piny/Repo.pm
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@omgwallhack.org>2011-05-31 00:20:07 -0700
committerJoe Rayhawk <jrayhawk@omgwallhack.org>2011-05-31 00:20:07 -0700
commit0e3caca27cf5ddc89f28bb620a967d43e085fc31 (patch)
treebcc7bd5d56ead121eadbfb9137f42a8b4b891b3d /libpiny/lib/Piny/Repo.pm
parentab2df0b7b3ff8020abadd9ad338600e771064961 (diff)
downloadpiny-code-0e3caca27cf5ddc89f28bb620a967d43e085fc31.tar.gz
piny-code-0e3caca27cf5ddc89f28bb620a967d43e085fc31.zip
FIXME: broken config copying.
Diffstat (limited to 'libpiny/lib/Piny/Repo.pm')
-rw-r--r--libpiny/lib/Piny/Repo.pm17
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!";