Added the possible deletion of the repository when deleting a subversion project.

This commit is contained in:
Loic d'Anterroches 2009-06-25 21:37:46 +02:00
parent fcefbe719f
commit 2ab52e7eaf
4 changed files with 60 additions and 2 deletions

View File

@ -66,6 +66,8 @@ need to put the following in your configuration file:
$cfg['idf_plugin_syncsvn_authz_file'] = '/home/svn/dav_svn.authz'; $cfg['idf_plugin_syncsvn_authz_file'] = '/home/svn/dav_svn.authz';
$cfg['idf_plugin_syncsvn_passwd_file'] = '/home/svn/dav_svn.passwd'; $cfg['idf_plugin_syncsvn_passwd_file'] = '/home/svn/dav_svn.passwd';
$cfg['idf_plugin_syncsvn_svn_path'] = '/home/svn/repositories'; $cfg['idf_plugin_syncsvn_svn_path'] = '/home/svn/repositories';
// Delete the corresponding repository when deleting the project
$cfg['idf_plugin_syncsvn_remove_orphans'] = false;
You can have more control over the permissions given to the owners, You can have more control over the permissions given to the owners,
members, extra authorized users and anonymous users if you want with members, extra authorized users and anonymous users if you want with

View File

@ -52,6 +52,9 @@ class IDF_Plugin_SyncSvn
case 'Pluf_User::passwordUpdated': case 'Pluf_User::passwordUpdated':
$plug->processSyncPasswd($params['user']); $plug->processSyncPasswd($params['user']);
break; break;
case 'IDF_Project::preDelete':
$plug->processSvnDelete($params['project']);
break;
} }
} }
@ -83,6 +86,31 @@ class IDF_Plugin_SyncSvn
$ll = exec($cmd, $output, $return); $ll = exec($cmd, $output, $return);
return ($return == 0); return ($return == 0);
} }
/**
* Remove the project from the drive and update the access rights.
*
* @param IDF_Project
* @return bool Success
*/
function processSvnDelete($project)
{
if (!Pluf::f('idf_plugin_syncsvn_remove_orphans', false)) {
return;
}
if ($project->getConf()->getVal('scm') != 'svn') {
return false;
}
$this->SyncAccess($project); // exclude $project
$shortname = $project->shortname;
if (false===($svn_path=Pluf::f('idf_plugin_syncsvn_svn_path',false))) {
throw new Pluf_Exception_SettingError("'idf_plugin_syncsvn_svn_path' must be defined in your configuration file.");
}
if (file_exists($svn_path.'/'.$shortname)) {
$cmd = Pluf::f('idf_exec_cmd_prefix', '').'rm -rf '.$svn_path.'/'.$shortname;
exec($cmd);
}
}
/** /**
* Synchronise an user's password. * Synchronise an user's password.
@ -156,8 +184,10 @@ class IDF_Plugin_SyncSvn
* We rebuild the complete file each time. This is just to be sure * We rebuild the complete file each time. This is just to be sure
* not to bork the rights when trying to just edit part of the * not to bork the rights when trying to just edit part of the
* file. * file.
*
* @param IDF_Project Possibly exclude a project (null)
*/ */
function SyncAccess() function SyncAccess($exclude=null)
{ {
$authz_file = Pluf::f('idf_plugin_syncsvn_authz_file'); $authz_file = Pluf::f('idf_plugin_syncsvn_authz_file');
$access_owners = Pluf::f('idf_plugin_syncsvn_access_owners', 'rw'); $access_owners = Pluf::f('idf_plugin_syncsvn_access_owners', 'rw');
@ -170,6 +200,9 @@ class IDF_Plugin_SyncSvn
} }
$fcontent = ''; $fcontent = '';
foreach (Pluf::factory('IDF_Project')->getList() as $project) { foreach (Pluf::factory('IDF_Project')->getList() as $project) {
if ($exclude and $exclude->id == $project->id) {
continue;
}
$conf = new IDF_Conf(); $conf = new IDF_Conf();
$conf->setProject($project); $conf->setProject($project);
if ($conf->getVal('scm') != 'svn' or if ($conf->getVal('scm') != 'svn' or

View File

@ -586,6 +586,28 @@ class IDF_Project extends Pluf_Model
*/ */
public function preDelete() public function preDelete()
{ {
/**
* [signal]
*
* IDF_Project::preDelete
*
* [sender]
*
* IDF_Project
*
* [description]
*
* This signal allows an application to perform special
* operations at the deletion of a project.
*
* [parameters]
*
* array('project' => $project)
*
*/
$params = array('project' => $this);
Pluf_Signal::send('IDF_Project::preDelete',
'IDF_Project', $params);
$what = array('IDF_Upload', 'IDF_Review', 'IDF_Issue', $what = array('IDF_Upload', 'IDF_Review', 'IDF_Issue',
'IDF_WikiPage', 'IDF_Commit', 'IDF_WikiPage', 'IDF_Commit',
); );

View File

@ -54,7 +54,8 @@ Pluf_Signal::connect('IDF_Project::created',
array('IDF_Plugin_SyncSvn', 'entry')); array('IDF_Plugin_SyncSvn', 'entry'));
Pluf_Signal::connect('Pluf_User::passwordUpdated', Pluf_Signal::connect('Pluf_User::passwordUpdated',
array('IDF_Plugin_SyncSvn', 'entry')); array('IDF_Plugin_SyncSvn', 'entry'));
Pluf_Signal::connect('IDF_Project::preDelete',
array('IDF_Plugin_SyncSvn', 'entry'));
# #
# Mercurial synchronization # Mercurial synchronization
Pluf_Signal::connect('IDF_Project::membershipsUpdated', Pluf_Signal::connect('IDF_Project::membershipsUpdated',