diff --git a/src/IDF/Plugin/SyncGit/Cron.php b/src/IDF/Plugin/SyncGit/Cron.php index 9cd393f..faff5ee 100644 --- a/src/IDF/Plugin/SyncGit/Cron.php +++ b/src/IDF/Plugin/SyncGit/Cron.php @@ -58,6 +58,17 @@ class IDF_Plugin_SyncGit_Cron } /** + * Mark export of git repositories for the daemon. + */ + public static function markExport() + { + foreach (Pluf::factory('IDF_Project')->getList() as $project) { + $rep = sprintf(Pluf::f('git_repositories'), $project->shortname); + IDF_Plugin_SyncGit_Serve::setGitExport($project->shortname, $rep); + } + } + + /** * Check if a sync is needed. * */ @@ -66,6 +77,7 @@ class IDF_Plugin_SyncGit_Cron if (file_exists(Pluf::f('idf_plugin_syncgit_sync_file'))) { @unlink(Pluf::f('idf_plugin_syncgit_sync_file')); self::sync(); + self::markExport(); } } } diff --git a/src/IDF/Plugin/SyncGit/Serve.php b/src/IDF/Plugin/SyncGit/Serve.php index 6ee1132..bbdafbc 100644 --- a/src/IDF/Plugin/SyncGit/Serve.php +++ b/src/IDF/Plugin/SyncGit/Serve.php @@ -231,6 +231,9 @@ class IDF_Plugin_SyncGit_Serve */ public function gitExportDeny($fullpath) { + if (!file_exists($fullpath)) { + return; // Not created yet. + } @unlink($fullpath.DIRECTORY_SEPARATOR.'git-daemon-export-ok'); if (file_exists($fullpath.DIRECTORY_SEPARATOR.'git-daemon-export-ok')) { throw new Exception('Cannot remove git-daemon-export-ok file.'); @@ -245,6 +248,9 @@ class IDF_Plugin_SyncGit_Serve */ public function gitExportAllow($fullpath) { + if (!file_exists($fullpath)) { + return; // Not created yet. + } touch($fullpath.DIRECTORY_SEPARATOR.'git-daemon-export-ok'); if (!file_exists($fullpath.DIRECTORY_SEPARATOR.'git-daemon-export-ok')) { throw new Exception('Cannot create git-daemon-export-ok file.'); diff --git a/src/IDF/relations.php b/src/IDF/relations.php index 52e7ea7..f18b35f 100644 --- a/src/IDF/relations.php +++ b/src/IDF/relations.php @@ -63,6 +63,8 @@ Pluf_Signal::connect('Pluf_User::passwordUpdated', # # Git synchronization +Pluf_Signal::connect('IDF_Project::membershipsUpdated', + array('IDF_Plugin_SyncGit', 'entry')); Pluf_Signal::connect('IDF_Key::postSave', array('IDF_Plugin_SyncGit', 'entry'));