diff --git a/src/IDF/Plugin/SyncMonotone.php b/src/IDF/Plugin/SyncMonotone.php index b347d37..64c8db6 100644 --- a/src/IDF/Plugin/SyncMonotone.php +++ b/src/IDF/Plugin/SyncMonotone.php @@ -37,6 +37,9 @@ class IDF_Plugin_SyncMonotone case 'IDF_Project::created': $plug->processProjectCreate($params['project']); break; + case 'IDF_Project::membershipsUpdated': + $plug->processMembershipsUpdated($params['project']); + break; case 'IDF_Project::preDelete': $plug->processProjectDelete($params['project']); break; @@ -62,8 +65,8 @@ class IDF_Plugin_SyncMonotone * 4) write monotonerc * 5) add the database as new local server in the usher configuration * 6) reload the running usher instance so it acknowledges the new server - * 7) create read-/write-permissions for the project and add all public - * keys to the project + * + * The initial right setup happens in processMembershipsUpdated() * * @param IDF_Project */ @@ -262,11 +265,25 @@ class IDF_Plugin_SyncMonotone // step 6) reload usher to pick up the new configuration // IDF_Scm_Monotone_Usher::reload(); + } + + /** + * Updates the read / write permissions for the monotone database + * + * @param IDF_Project + */ + public function processMembershipsUpdated($project) + { + $projecttempl = Pluf::f('mtn_repositories', false); + if ($projecttempl === false) { + throw new IDF_Scm_Exception( + '"mtn_repositories" must be defined in your configuration file.' + ); + } + + $shortname = $project->shortname; + $projectpath = sprintf($projecttempl, $shortname); - // - // step 7) add public monotone keys for the project to - // read-permissions, write-permissions and the database - // $mtn = IDF_Scm_Monotone::factory($project); $stdio = $mtn->getStdio(); @@ -466,11 +483,11 @@ class IDF_Plugin_SyncMonotone } $wildcard_section = null; - foreach ($parsed_read_perms as $stanzas) { - foreach ($stanzas as $stanza_line) { + for ($i=0; $iprivate === true) { + if ($project->private) { $read_perms = file_get_contents($projectpath.'/read-permissions'); $parsed_read_perms = array(); try { @@ -588,14 +605,13 @@ class IDF_Plugin_SyncMonotone // while we add new keys only to an existing wild-card entry // we remove dropped keys from all sections since the key // should be simply unavailable for all of them - foreach ($parsed_read_perms as $stanzas) { - for ($i=0; $i