diff --git a/scripts/git-post-update b/scripts/git-post-update index 2284d40..08c7866 100755 --- a/scripts/git-post-update +++ b/scripts/git-post-update @@ -12,11 +12,13 @@ # to enable it later, you need to symlink it as "post-update" in your # $GIT_DIR/hooks folder. # +# www$ chmod +x /home/www/indefero/scripts/git-post-update # git$ cd /home/git/repositories/project.git/hooks # git$ ln -s /home/www/indefero/scripts/git-post-update post-update # SCRIPTDIR=$(dirname $(readlink -f $0)) +FULL_GIT_DIR=$(readlink -f $GIT_DIR) PHP_POST_UPDATE=$SCRIPTDIR/gitpostupdate.php -echo php $PHP_POST_UPDATE $GIT_DIR | at now +echo php $PHP_POST_UPDATE $FULL_GIT_DIR | at now > /dev/null 2>&1 diff --git a/src/IDF/Plugin/SyncGit.php b/src/IDF/Plugin/SyncGit.php index 063f85c..01707f0 100644 --- a/src/IDF/Plugin/SyncGit.php +++ b/src/IDF/Plugin/SyncGit.php @@ -66,7 +66,7 @@ class IDF_Plugin_SyncGit { // Find the corresponding project. $git_dir = substr($params['git_dir'], 0, -4); // Chop the ".git" - $elts = explode('#/#', $git_dir, -1, PREG_SPLIT_NO_EMPTY); + $elts = preg_split('#/#', $git_dir, -1, PREG_SPLIT_NO_EMPTY); $pname = array_pop($elts); try { $project = IDF_Project::getOr404($pname); diff --git a/src/IDF/Plugin/SyncGit/Serve.php b/src/IDF/Plugin/SyncGit/Serve.php index b69b8ef..0ba5de3 100644 --- a/src/IDF/Plugin/SyncGit/Serve.php +++ b/src/IDF/Plugin/SyncGit/Serve.php @@ -203,7 +203,29 @@ class IDF_Plugin_SyncGit_Serve Pluf_Log::error(array('IDF_Plugin_Git_Serve::initRepository', $res, $fullpath)); throw new Exception(sprintf('Init repository error, exit status %d.', $res)); } - Pluf_Log::info(array('IDF_Plugin_Git_Serve::initRepository', 'success', $fullpath)); + Pluf_Log::event(array('IDF_Plugin_Git_Serve::initRepository', 'success', $fullpath)); + // Add the post-update hook by removing the original one and add the + // Indefero's one. + $p = realpath(dirname(__FILE__).'/../../../../scripts/git-post-update'); + $p = Pluf::f('idf_plugin_syncgit_post_update', $p); + if (!@unlink($fullpath.'/hooks/post-update')) { + Pluf_Log::warn(array('IDF_Plugin_Git_Serve::initRepository', + 'post-update hook removal error.', + $fullpath.'/hooks/post-update')); + return; + } + exec(sprintf(Pluf::f('idf_exec_cmd_prefix', '').'ln -s %s %s', + escapeshellarg($p), + escapeshellarg($fullpath.'/hooks/post-update')), + $out, $res); + if ($res != 0) { + Pluf_Log::warn(array('IDF_Plugin_Git_Serve::initRepository', + 'post-update hook creation error.', + $fullpath.'/hooks/post-update')); + return; + } + Pluf_Log::debug(array('IDF_Plugin_Git_Serve::initRepository', + 'Added post-update hook.', $fullpath)); } diff --git a/src/IDF/Scm.php b/src/IDF/Scm.php index 3f24f58..94cf5ec 100644 --- a/src/IDF/Scm.php +++ b/src/IDF/Scm.php @@ -393,11 +393,11 @@ class IDF_Scm * Sync the changes in the repository with the timeline. * */ - public static function syncTimeline($project) + public static function syncTimeline($project, $force=false) { $cache = Pluf_Cache::factory(); $key = 'IDF_Scm:'.$project->shortname.':lastsync'; - if (null === ($res=$cache->get($key))) { + if ($force or null === ($res=$cache->get($key))) { $scm = IDF_Scm::get($project); if ($scm->isAvailable()) { foreach ($scm->getChangeLog($scm->getMainBranch(), 25) as $change) {