[Rt-commit] r5895 - commitbit/lib/CommitBit/Model
clkao at bestpractical.com
clkao at bestpractical.com
Sun Sep 10 20:05:55 EDT 2006
Author: clkao
Date: Sun Sep 10 20:05:55 2006
New Revision: 5895
Modified:
commitbit/lib/CommitBit/Model/Repository.pm
Log:
Add a bunch of svn interaction code.
Modified: commitbit/lib/CommitBit/Model/Repository.pm
==============================================================================
--- commitbit/lib/CommitBit/Model/Repository.pm (original)
+++ commitbit/lib/CommitBit/Model/Repository.pm Sun Sep 10 20:05:55 2006
@@ -4,6 +4,7 @@
package CommitBit::Model::Repository;
use Jifty::DBI::Schema;
+use File::Spec;
use CommitBit::Record schema {
@@ -24,17 +25,43 @@
# Your model-specific methods go here.
-sub init_repository {}
+# XXX: make sure svn/svnadmin is in path during compile time.
+sub _svnadmin {
+ my $self = shift;
+ system("svnadmin", @_);
+}
+
+sub _svn {
+ my $self = shift;
+ system("svn", @_);
+}
+
+sub create {
+ my $self = shift;
+ my ($id, $msg) = $self->SUPER::create(@_);
+
+ if ($id) {
+ # XXX: when failed rollback the create?
+ $self->init_repository;
+ }
+
+ return ($id, $msg);
+}
+
+sub init_repository {
+ my $self = shift;
+ $self->_svnadmin('create', $self->path);
+}
sub add_project {
my $self = shift;
- # mkdir repository/project
- # mkdir repository/project/branches
- # mkdir repository/project/tags
- # mkdir repository/project/trunk
+ my $project = shift;
- $self->write_authz_file();
+ $self->_svn('mkdir', -m => 'Project '.$project->name.' init by CommitBit',
+ map { "file://".File::Spec::Unix->catdir($self->path, $project->root_path, $_)}
+ '', 'trunk', 'branches', 'tags');
+ $self->write_authz_file();
}
sub remove_project {}
@@ -86,7 +113,7 @@
sub authz_file_path {
my $self = shift;
- Carp::cluck "unwritten"
+ return File::Spec->catdir($self->path, 'conf', 'authz');
}
More information about the Rt-commit
mailing list