summaryrefslogtreecommitdiff
path: root/libpiny/lib
diff options
context:
space:
mode:
authorJulian Blake Kongslie <jblake@omgwallhack.org>2011-05-07 00:01:27 -0700
committerJulian Blake Kongslie <jblake@omgwallhack.org>2011-05-07 00:01:27 -0700
commit62abed37202a4651d210c56cd2cdf88d5ac6aad7 (patch)
tree3502bb56566816a5250926ff08298f15fde7bd5f /libpiny/lib
parentc70ee7e1e1112fe9cc734b14b2783d27f04027d6 (diff)
downloadpiny-code-62abed37202a4651d210c56cd2cdf88d5ac6aad7.tar.gz
piny-code-62abed37202a4651d210c56cd2cdf88d5ac6aad7.zip
Support creating repos from a source template.
Diffstat (limited to 'libpiny/lib')
-rw-r--r--libpiny/lib/Piny/Config.pm1
-rw-r--r--libpiny/lib/Piny/Repo.pm24
2 files changed, 15 insertions, 10 deletions
diff --git a/libpiny/lib/Piny/Config.pm b/libpiny/lib/Piny/Config.pm
index aa4a284..8a611e5 100644
--- a/libpiny/lib/Piny/Config.pm
+++ b/libpiny/lib/Piny/Config.pm
@@ -216,6 +216,7 @@ sub tweakable {
# Global tweakables, which only make sense in the global config file.
tweakable "piny_adminemail" => "jrayhawk\@omgwallhack.org", 'Str';
+tweakable "piny_template" => undef, 'Maybe[PathDir]';
# Repo-specific tweakables, in the repos' .git/config files.
tweakable "piny_ikiwikidestdir" => "/srv/www/piny.be/", 'PathDir';
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm
index 134894c..cb3754f 100644
--- a/libpiny/lib/Piny/Repo.pm
+++ b/libpiny/lib/Piny/Repo.pm
@@ -382,7 +382,11 @@ sub all_repos {
# Only sets up needed data; ->rebuild takes care of the rest.
sub create {
- my ( $class, $name, $description ) = @_;
+ my ( $class, $name, $description, $source ) = @_;
+
+ if ( not defined $source) {
+ $source = Piny::Environment->config->piny_template;
+ };
my $user = Piny::Environment->instance->user;
@@ -393,15 +397,15 @@ sub create {
mkdir( $repo->path ) or die "The repo $name appears to already exist! ($!)";
- $ENV{"GIT_DIR"} = $repo->path;
- system( "/usr/bin/git", "init", "--bare", "--quiet", "--shared" ) and die "Could not initialize git repo!";
- delete $ENV{"GIT_DIR"};
-
-# if source repo is defined {
-# $ENV{"GIT_DIR"} = $source;
-# system( "/usr/bin/git", "push", "--mirror", $repo->path ) and die "Could not push refs to new repository!";
-# delete $ENV{"GIT_DIR"};
-# }
+ if ( defined $source ) {
+ $ENV{"GIT_DIR"} = $source;
+ system( "/usr/bin/git", "push", "--mirror", $repo->path ) and die "Could not push refs to new repository!";
+ delete $ENV{"GIT_DIR"};
+ } else {
+ $ENV{"GIT_DIR"} = $repo->path;
+ system( "/usr/bin/git", "init", "--bare", "--quiet", "--shared" ) and die "Could not initialize git repo!";
+ delete $ENV{"GIT_DIR"};
+ };
system( "/bin/chown", "-R", $user->name, $repo->path . "/objects" ) and die "Could not change ownership of $_ for repo: $!";