[Rt-commit] r5890 - in commitbit: . bin doc etc lib lib/CommitBit
lib/CommitBit/Action log share share/po share/web
share/web/static share/web/templates share/web/templates/project t
jesse at bestpractical.com
jesse at bestpractical.com
Sun Sep 10 16:30:00 EDT 2006
Author: jesse
Date: Sun Sep 10 16:29:58 2006
New Revision: 5890
Added:
commitbit/Makefile.PL
commitbit/bin/
commitbit/bin/jifty (contents, props changed)
commitbit/doc/
commitbit/doc/integration
commitbit/etc/
commitbit/etc/config.yml
commitbit/lib/
commitbit/lib/CommitBit/
commitbit/lib/CommitBit/Action/
commitbit/lib/CommitBit/Dispatcher.pm
commitbit/lib/CommitBit/Model/
commitbit/lib/CommitBit/Model/Project.pm
commitbit/lib/CommitBit/Model/ProjectMember.pm
commitbit/lib/CommitBit/Model/Repository.pm
commitbit/lib/CommitBit/Model/User.pm
commitbit/log/
commitbit/share/
commitbit/share/po/
commitbit/share/web/
commitbit/share/web/static/
commitbit/share/web/templates/
commitbit/share/web/templates/index.html
commitbit/share/web/templates/project/
commitbit/share/web/templates/project/.people.swp (contents, props changed)
commitbit/share/web/templates/project/index.html
commitbit/share/web/templates/project/people
commitbit/t/
commitbit/t/00-model-Project.t (contents, props changed)
commitbit/t/00-model-ProjectMember.t (contents, props changed)
commitbit/t/00-model-Repository.t (contents, props changed)
commitbit/t/00-model-User.t (contents, props changed)
Modified:
commitbit/ (props changed)
Log:
r27335 at pinglin: jesse | 2006-09-10 21:29:47 +0100
* first sketch
Added: commitbit/Makefile.PL
==============================================================================
--- (empty file)
+++ commitbit/Makefile.PL Sun Sep 10 16:29:58 2006
@@ -0,0 +1,6 @@
+use inc::Module::Install;
+name('CommitBit');
+version('0.01');
+requires('Jifty' => '0.60728');
+
+WriteAll;
Added: commitbit/bin/jifty
==============================================================================
--- (empty file)
+++ commitbit/bin/jifty Sun Sep 10 16:29:58 2006
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use File::Basename qw(dirname);
+use UNIVERSAL::require;
+
+BEGIN {
+ Jifty::Util->require or die $UNIVERSAL::require::ERROR;
+ my $root = Jifty::Util->app_root;
+ unshift @INC, "$root/lib" if ($root);
+}
+
+use Jifty::Script;
+$SIG{INT} = $SIG{TERM} = sub { warn "Stopped\n"; exit; };
+Jifty::Script->dispatch();
Added: commitbit/doc/integration
==============================================================================
--- (empty file)
+++ commitbit/doc/integration Sun Sep 10 16:29:58 2006
@@ -0,0 +1,18 @@
+* pre-commit hook for write acls
+ shouldn't require the jifty acl server to be running.
+* password-writer for svnserve
+ (plaintext)
+* password-writer for htpasswd
+ (htpasswd)
+
+* repo creator
+
+* repo commitbit injector
+
+* user manager
+ * create user
+ * manage project memberships
+ * reset password
+
+* project mnanager
+
Added: commitbit/etc/config.yml
==============================================================================
--- (empty file)
+++ commitbit/etc/config.yml Sun Sep 10 16:29:58 2006
@@ -0,0 +1,36 @@
+---
+framework:
+ AdminMode: 1
+ ApplicationClass: CommitBit
+ ApplicationName: CommitBit
+ Database:
+ Database: commitbit
+ Driver: SQLite
+ Host: localhost
+ Password: ''
+ RecordBaseClass: Jifty::DBI::Record::Cachable
+ User: ''
+ Version: 0.0.1
+ DevelMode: 1
+ L10N:
+ PoDir: share/po
+ LogLevel: DEBUG
+ Mailer: Sendmail
+ MailerArgs: []
+
+ Plugins: []
+
+ Web:
+ BaseURL: http://localhost
+ DataDir: var/mason
+ Globals: []
+
+ MasonConfig:
+ autoflush: 0
+ default_escape_flags: h
+ error_format: text
+ error_mode: fatal
+ Port: 8888
+ ServeStaticFiles: 1
+ StaticRoot: share/web/static
+ TemplateRoot: share/web/templates
Added: commitbit/lib/CommitBit/Dispatcher.pm
==============================================================================
--- (empty file)
+++ commitbit/lib/CommitBit/Dispatcher.pm Sun Sep 10 16:29:58 2006
@@ -0,0 +1,19 @@
+package CommitBit::Dispatcher;
+use Jifty::Dispatcher -base;
+
+on qr'project/(.+?)(/.*)$' => run {
+ my $name = $1;
+ my $path = $2;
+ warn "Name - $name - $path";
+ my $project = CommitBit::Model::Project->new();
+ $project->load_by_cols( name => $name );
+ unless ($project->id) {
+ redirect '/__jifty/error/project/not_found';
+ }
+
+ set project => $project;
+
+ show( '/project/' . $path || '/project/index.html' );
+};
+
+1;
Added: commitbit/lib/CommitBit/Model/Project.pm
==============================================================================
--- (empty file)
+++ commitbit/lib/CommitBit/Model/Project.pm Sun Sep 10 16:29:58 2006
@@ -0,0 +1,34 @@
+use strict;
+use warnings;
+
+package CommitBit::Model::Project;
+use Jifty::DBI::Schema;
+
+use CommitBit::Model::Repository;
+
+use CommitBit::Record schema {
+ column 'name' =>
+ type is 'text';
+ column 'description' =>
+ type is 'text';
+ column 'root_path' =>
+ type is 'text';
+ column 'repository' =>
+ refers_to CommitBit::Model::Repository;
+
+ column 'public' =>
+ type is 'boolean',
+ default is '1';
+
+};
+
+# Your model-specific methods go here.
+
+sub members {}
+sub admins {}
+
+
+
+
+1;
+
Added: commitbit/lib/CommitBit/Model/ProjectMember.pm
==============================================================================
--- (empty file)
+++ commitbit/lib/CommitBit/Model/ProjectMember.pm Sun Sep 10 16:29:58 2006
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+
+package CommitBit::Model::ProjectMember;
+use Jifty::DBI::Schema;
+
+use CommitBit::Model::User;
+use CommitBit::Model::Project;
+
+
+use CommitBit::Record schema {
+ column user =>
+ refers_to CommitBit::Model::User;
+ column project =>
+ refers_to CommitBit::Model::Project;
+
+ column role =>
+ type is 'text',
+ valid_values are qw(observer author administrator),
+ default is 'observer';
+
+};
+
+# Your model-specific methods go here.
+
+1;
+
Added: commitbit/lib/CommitBit/Model/Repository.pm
==============================================================================
--- (empty file)
+++ commitbit/lib/CommitBit/Model/Repository.pm Sun Sep 10 16:29:58 2006
@@ -0,0 +1,149 @@
+use strict;
+use warnings;
+use Carp;
+
+package CommitBit::Model::Repository;
+use Jifty::DBI::Schema;
+
+use CommitBit::Record schema {
+
+ column name =>
+ type is 'text';
+ column path =>
+ type is 'text';
+ column description =>
+ type is 'text',
+ render_as 'textarea';
+ column member_url =>
+ type is 'text';
+ column anon_url =>
+ type is 'text';
+
+
+};
+
+# Your model-specific methods go here.
+
+sub init_repository {}
+
+sub add_project {
+ my $self = shift;
+ # mkdir repository/project
+ # mkdir repository/project/branches
+ # mkdir repository/project/tags
+ # mkdir repository/project/trunk
+
+ $self->write_authz_file();
+
+}
+
+sub remove_project {}
+
+sub write_password_files {
+ my $self = shift;
+ $self->write_htpasswd_file();
+ $self->write_svnserve_passwd_file();
+}
+
+sub write_htpasswd_file {
+ my $self = shift;
+ with_write_lock {
+ };
+}
+
+sub write_svnserve_passwd_file {
+ my $self = shift;
+ with_write_lock {
+ };
+
+}
+
+sub write_authz_file {
+ my $self = shift;
+
+ my $authz = {};
+ my $projects = CommitBit::Model::ProjectCollection->new();
+
+ with_write_lock {
+
+ open( my $file, ">", $self->authz_file_path ) || die $@;
+ while ( my $project = $projects->next ) {
+ print $file $self->autogenerated_file_warning;
+ print $file "[" . $project->root_path . "]\n" || die $@;
+ foreach my $user ( @{ $project->members->items_arrayref } ) {
+ print $file $user->username . " = rw\n" || die $@;
+ }
+ if ($project->public) {
+ print $file "* = r\n";
+ }
+ }
+
+ close($file) || die $@;
+
+ };
+
+}
+
+sub authz_file_path {
+ my $self = shift;
+ Carp::cluck "unwritten"
+}
+
+
+sub write_svnserv_config {
+ my $self = shift;
+ with_write_lock {
+ };
+
+
+
+}
+sub write_httpd_config {
+ my $self = shift;
+ with_write_lock {
+
+ };
+
+
+}
+
+
+sub with_write_lock (&) {
+ my $sub = shift;
+ eval {
+ obtain_write_lock() || Carp::croak "Couldn't get write lock :(";
+ &$sub();
+ release_write_lock() || Carp::croak "Couldn't release write lock :(";
+ return 1;
+ };
+ return 0;
+}
+
+sub obtain_write_lock {
+
+ return 1;
+
+}
+
+sub release_write_lock {
+}
+
+
+sub autogenerated_file_warning {
+ my $self = shift;
+ my $msg = <<EOF;
+
+# This file was autogenerated by CommitBit @{[$CommitBit::VERSION]} at @{[scalar gmtime]} GMT.
+#
+# If you edit this file by hand, you risk losing your changes the next
+# time CommitBit automatically rewrites this file.
+#
+# DO NOT EDIT THIS FILE BY HAND.
+
+EOF
+
+ return $msg;
+}
+
+1;
+
Added: commitbit/lib/CommitBit/Model/User.pm
==============================================================================
--- (empty file)
+++ commitbit/lib/CommitBit/Model/User.pm Sun Sep 10 16:29:58 2006
@@ -0,0 +1,45 @@
+use strict;
+use warnings;
+
+package CommitBit::Model::User;
+use Jifty::DBI::Schema;
+
+use CommitBit::Record schema {
+ column 'email' =>
+ type is 'text';
+ column 'username' =>
+ type is 'text',
+ is 'unique',
+ is 'immutable',
+ is 'mandatory';
+ column email_validated =>
+ type is 'boolean',
+ default is '0';
+ column 'password' =>
+ type is 'text',
+ render_as 'password';
+ column 'nickname' =>
+ type is 'text';
+ column 'created' =>
+ type is 'timestamp',
+ is immutable;
+ column admin =>
+ type is 'boolean',
+ default is '0';
+
+};
+
+# Your model-specific methods go here.
+
+sub _brief_description {
+ 'name_and_email';
+
+}
+
+sub name_and_email {
+ my $self = shift;
+ return $self->username . " <".$self->email.">";
+}
+
+1;
+
Added: commitbit/share/web/templates/index.html
==============================================================================
--- (empty file)
+++ commitbit/share/web/templates/index.html Sun Sep 10 16:29:58 2006
@@ -0,0 +1,15 @@
+<&|/_elements/wrapper, title => 'Commit bit!' &>
+
+<h1><%_('Welcome to CommitBit')%></h1>
+
+
+<p><%_('Pick a project')%></p>
+<dl>
+% my $projects = CommitBit::Model::ProjectCollection->new;
+% $projects->unlimit();
+% while ( my $p = $projects->next ) {
+<dt><%Jifty->web->link( url => '/project/'.$p->name, label => $p->name)%></dt>
+<dd<%$p->description%></dd>
+% }
+</dl>
+</&>
Added: commitbit/share/web/templates/project/.people.swp
==============================================================================
Binary file. No diff available.
Added: commitbit/share/web/templates/project/index.html
==============================================================================
--- (empty file)
+++ commitbit/share/web/templates/project/index.html Sun Sep 10 16:29:58 2006
@@ -0,0 +1,4 @@
+<%args>
+$project
+</%args>
+HI. <%$project->name%>
Added: commitbit/share/web/templates/project/people
==============================================================================
--- (empty file)
+++ commitbit/share/web/templates/project/people Sun Sep 10 16:29:58 2006
@@ -0,0 +1,9 @@
+<h1>People involved with <%$project->name%>
+
+<h2><%_('Committers')%></h2>
+% my $committers = $project->members;
+<ul>
+% while (my $committer = $committers->next) {
+<li><%comitter->name_and_email%></li>
+% }
+</ul>
Added: commitbit/t/00-model-Project.t
==============================================================================
--- (empty file)
+++ commitbit/t/00-model-Project.t Sun Sep 10 16:29:58 2006
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the Project model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('CommitBit::Model::Project');
+
+# Grab a system user
+my $system_user = CommitBit::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = CommitBit::Model::Project->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "Project create returned success");
+ok($o->id, "New Project has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "Project create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = CommitBit::Model::ProjectCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: commitbit/t/00-model-ProjectMember.t
==============================================================================
--- (empty file)
+++ commitbit/t/00-model-ProjectMember.t Sun Sep 10 16:29:58 2006
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the ProjectMember model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('CommitBit::Model::ProjectMember');
+
+# Grab a system user
+my $system_user = CommitBit::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = CommitBit::Model::ProjectMember->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "ProjectMember create returned success");
+ok($o->id, "New ProjectMember has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "ProjectMember create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = CommitBit::Model::ProjectMemberCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: commitbit/t/00-model-Repository.t
==============================================================================
--- (empty file)
+++ commitbit/t/00-model-Repository.t Sun Sep 10 16:29:58 2006
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the Repository model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('CommitBit::Model::Repository');
+
+# Grab a system user
+my $system_user = CommitBit::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = CommitBit::Model::Repository->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "Repository create returned success");
+ok($o->id, "New Repository has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "Repository create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = CommitBit::Model::RepositoryCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
Added: commitbit/t/00-model-User.t
==============================================================================
--- (empty file)
+++ commitbit/t/00-model-User.t Sun Sep 10 16:29:58 2006
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the User model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('CommitBit::Model::User');
+
+# Grab a system user
+my $system_user = CommitBit::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = CommitBit::Model::User->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "User create returned success");
+ok($o->id, "New User has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "User create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = CommitBit::Model::UserCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
More information about the Rt-commit
mailing list