[vhffs-dev] [739] Change cvs to the new naming scheme (complete path in db group/ cvsroot) in order to have a simple unicity constraint |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [739] Change cvs to the new naming scheme (complete path in db group/ cvsroot) in order to have a simple unicity constraint
- From: subversion@xxxxxxxxx
- Date: Tue, 31 Jul 2007 02:00:32 +0200
Revision: 739
Author: gradator
Date: 2007-07-31 00:00:31 +0000 (Tue, 31 Jul 2007)
Log Message:
-----------
Change cvs to the new naming scheme (complete path in db group/cvsroot) in order to have a simple unicity constraint
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
trunk/vhffs-backend/src/pgsql/initdb.sql.in
trunk/vhffs-panel/cvs/create.pl
trunk/vhffs-panel/templates/cvs/create.tmpl
trunk/vhffs-public/group.pl
trunk/vhffs-robots/src/create_viewvcconf.pl
Modified: trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Cvs.pm 2007-07-30 23:26:53 UTC (rev 738)
+++ trunk/vhffs-api/src/Vhffs/Services/Cvs.pm 2007-07-31 00:00:31 UTC (rev 739)
@@ -52,17 +52,17 @@
=pod
-=head2 check_cvsroot
+=head2 check_name
- die("Invalid CVS root\n") unless(Vhffs::Services::Cvs::check_cvsroot($cvsroot));
+ die("Invalid CVS root\n") unless(Vhffs::Services::Cvs::check_name($cvsroot));
Checks whether a cvsroot is valid or not.
=cut
-sub check_cvsroot($) {
- my $cvsroot = shift;
- return (defined($cvsroot) && ($cvsroot =~ /^[a-z0-9]+$/));
+sub check_name($) {
+ my $name = shift;
+ return ($name =~ /^[a-z0-9]+\/[a-z0-9]{3,64}$/);
}
sub delete
@@ -92,7 +92,7 @@
{
my ($main, $cvsroot, $description, $user, $group) = @_;
return undef unless(defined($user) && defined($group));
- return undef unless(check_cvsroot($cvsroot));
+ return undef unless(check_name($cvsroot));
my $cvs;
my $dbh = $main->get_db_object();
@@ -192,7 +192,7 @@
my $self = shift;
return undef if( ! defined $self );
- return( $self->{'main'}->get_config->get_datadir . "/cvs/cvsroot/" . $self->get_group->get_groupname . "/" . $self->get_cvsroot );
+ return( $self->{'main'}->get_config->get_datadir . "/cvs/cvsroot/" . $self->get_cvsroot );
}
sub get_by_cvsroot {
Modified: trunk/vhffs-backend/src/pgsql/initdb.sql.in
===================================================================
--- trunk/vhffs-backend/src/pgsql/initdb.sql.in 2007-07-30 23:26:53 UTC (rev 738)
+++ trunk/vhffs-backend/src/pgsql/initdb.sql.in 2007-07-31 00:00:31 UTC (rev 739)
@@ -275,7 +275,7 @@
ALTER TABLE vhffs_pgsql ADD CONSTRAINT vhffs_pgsql_unique_dbname UNIQUE (dbname);
ALTER TABLE vhffs_pgsql ADD CONSTRAINT vhffs_pgsql_unique_dbuser UNIQUE (dbuser);
ALTER TABLE vhffs_repository ADD CONSTRAINT vhffs_repository_unique_name UNIQUE (name);
-ALTER TABLE vhffs_svn ADD CONSTRAINT vhffs_svn_unique_reponame_per_owner UNIQUE (reponame);
+ALTER TABLE vhffs_svn ADD CONSTRAINT vhffs_svn_unique_reponame UNIQUE (reponame);
ALTER TABLE vhffs_dns ADD CONSTRAINT vhffs_dns_unique_domain UNIQUE (domain);
ALTER TABLE vhffs_ml ADD CONSTRAINT vhffs_ml_unique_address UNIQUE (local_part, domain);
ALTER TABLE vhffs_ml_subscribers ADD CONSTRAINT vhffs_ml_subscribers_member_list UNIQUE (ml_id, member);
Modified: trunk/vhffs-panel/cvs/create.pl
===================================================================
--- trunk/vhffs-panel/cvs/create.pl 2007-07-30 23:26:53 UTC (rev 738)
+++ trunk/vhffs-panel/cvs/create.pl 2007-07-31 00:00:31 UTC (rev 739)
@@ -56,26 +56,28 @@
my $maintemplate = $panel->{'template'};
my $user = $panel->{'user'};
my $group = $panel->{'group'};
+my $groupname = $panel->{'groupname'};
my $cgi = $panel->{cgi};
my $submitted = defined($cgi->param('cvs_submit'));
-my $repo_name;
+my $reponame;
my $description;
my $templatedir = $vhffs->get_config->get_templatedir;
if($submitted) {
- $repo_name = $cgi->param('REPOSITORY_NAME');
+ $reponame = $cgi->param('REPOSITORY_NAME');
+ my $fullreponame = $groupname.'/'.$reponame;
$description = $cgi->param('DESCRIPTION');
- if( $repo_name !~ /^[a-z0-9]+$/ ) {
- $panel->add_error( gettext('Your repository name is not correct. It must contains only caracter and numbers') );
- } elsif( length( $repo_name ) < 3 ) {
- $panel->add_error( gettext('Your repository name is not correct. It must contains at least 3 caracters') );
+ if(!(defined $reponame && defined $description)) {
+ $panel->add_error( gettext('CGI error') );
+ } elsif( !Vhffs::Services::Cvs::check_name($fullreponame) ) {
+ $panel->add_error( gettext('Invalid reponame. It must contain between 3 and 64 characters, only lowercase letters and numbers') );
} elsif( $description =~ /^\s*$/ ) {
$panel->add_error( gettext('You must enter a description') );
} else {
#Create CVS
- my $cvs = Vhffs::Panel::Cvs::create_cvs( $vhffs, $repo_name, $description, $user , $group );
+ my $cvs = Vhffs::Panel::Cvs::create_cvs( $vhffs, $fullreponame, $description, $user , $group );
if( defined $cvs ) {
my $url = '/panel.pl?project='.$panel->{groupname}.'&msg='.gettext('The CVS object was successfully created !');
$panel->redirect($url);
@@ -85,7 +87,7 @@
}
} else {
# Avoid warnings with CGI::escapeHTML
- $repo_name = '';
+ $reponame = '';
$description = '';
}
@@ -95,7 +97,7 @@
$panel->set_title( gettext('Create a CVS Repository') );
$template->param( REPOSITORY_NAME => gettext("Repository Name") );
- $template->param( REPOSITORY_VALUE => CGI::escapeHTML($repo_name) );
+ $template->param( REPOSITORY_VALUE => CGI::escapeHTML($reponame) );
$template->param( GROUP_NAME => gettext("Group owning this CVS") );
$template->param( GROUP => $group->get_groupname );
Modified: trunk/vhffs-panel/templates/cvs/create.tmpl
===================================================================
--- trunk/vhffs-panel/templates/cvs/create.tmpl 2007-07-30 23:26:53 UTC (rev 738)
+++ trunk/vhffs-panel/templates/cvs/create.tmpl 2007-07-31 00:00:31 UTC (rev 739)
@@ -9,7 +9,7 @@
<label for="REPOSITORY_NAME">
<TMPL_VAR NAME="REPOSITORY_NAME">:
</label>
- <input type="text" name="REPOSITORY_NAME" id="REPOSITORY_NAME" value="<tmpl_var name="REPOSITORY_VALUE">"/>
+ <TMPL_VAR NAME="GROUP">/<input type="text" name="REPOSITORY_NAME" id="REPOSITORY_NAME" value="<tmpl_var name="REPOSITORY_VALUE">"/>
</p>
<p>
<label for="PROJECT_USAGE">
Modified: trunk/vhffs-public/group.pl
===================================================================
--- trunk/vhffs-public/group.pl 2007-07-30 23:26:53 UTC (rev 738)
+++ trunk/vhffs-public/group.pl 2007-07-31 00:00:31 UTC (rev 739)
@@ -152,7 +152,9 @@
{
$subtemplate = new HTML::Template( filename => $templatedir."/public/misc/cvs-part.tmpl" );
$subtemplate->param( CVSROOT => $_->get_cvsroot );
- $subtemplate->param( CVSURL => $vhffs->get_config->get_cvsweburl . '/cvs_' . $group->get_groupname . '_' . $_->get_cvsroot . '/' );
+ my $cvspath = $_->get_cvsroot;
+ $cvspath =~ s/\//_/;
+ $subtemplate->param( CVSURL => $vhffs->get_config->get_cvsweburl . '/cvs_' . $cvspath . '/' );
$output .= $subtemplate->output;
}
Modified: trunk/vhffs-robots/src/create_viewvcconf.pl
===================================================================
--- trunk/vhffs-robots/src/create_viewvcconf.pl 2007-07-30 23:26:53 UTC (rev 738)
+++ trunk/vhffs-robots/src/create_viewvcconf.pl 2007-07-31 00:00:31 UTC (rev 739)
@@ -59,7 +59,9 @@
{
if( $cvs->is_public == 1 )
{
- $cvsroots .= " cvs_" . $cvs->get_group->get_groupname . "_" . $cvs->get_cvsroot . ": " . $cvs->get_dir . ",\n";
+ my $cvspath = $cvs->get_cvsroot;
+ $cvspath =~ s/\//_/;
+ $cvsroots .= " cvs_" . $cvspath . ": " . $cvs->get_dir . ",\n";
}
}
}