diff --git a/scripts/svn-post-commit b/scripts/svn-post-commit new file mode 100644 index 0000000..54c85a3 --- /dev/null +++ b/scripts/svn-post-commit @@ -0,0 +1,24 @@ +#!/bin/sh +# +# This hook does only one thing: +# +# 1. It calls the svnpostcommit.php script with the current repository +# and revision as argument. The svnpostcommit.php script will then +# trigger the 'svnpostcommit.php::run' event with the repository path +# and revision as arguments together with merged $_ENV and $_SERVER +# array. +# +# This hook is normally installed automatically at the creation of your +# repository if you have everything configured correctly. If you want +# to enable it later, you need to symlink it as "post-commit" in your +# $REPOSITORY/hooks folder. +# +# www$ chmod +x /home/www/indefero/scripts/svn-post-commit +# www$ cd /home/svn/repositories/project/hooks +# www$ ln -s /home/www/indefero/scripts/svn-post-commit post-commit +# + +SCRIPTDIR=$(dirname $(readlink -f $0)) +PHP_POST_COMMIT=$SCRIPTDIR/svnpostcommit.php + +echo php $PHP_POST_COMMIT "$1" "$2" | at now > /dev/null 2>&1 diff --git a/scripts/svnpostcommit.php b/scripts/svnpostcommit.php new file mode 100644 index 0000000..d3430b9 --- /dev/null +++ b/scripts/svnpostcommit.php @@ -0,0 +1,61 @@ + '/path/to/subversion/repository', + * 'revision' => 1234, + * 'env' => array_merge($_ENV, $_SERVER)); + * + */ +$params = array('repo_dir' => $argv[1], + 'revision' => $argv[2], + 'env' => array_merge($_ENV, $_SERVER)); +Pluf_Signal::send('svnpostcommit.php::run', 'svnpostcommit.php', $params); + + + diff --git a/src/IDF/Plugin/SyncSvn.php b/src/IDF/Plugin/SyncSvn.php index 8aa3c49..f4ea12d 100644 --- a/src/IDF/Plugin/SyncSvn.php +++ b/src/IDF/Plugin/SyncSvn.php @@ -55,6 +55,9 @@ class IDF_Plugin_SyncSvn case 'IDF_Project::preDelete': $plug->processSvnDelete($params['project']); break; + case 'svnpostcommit.php::run': + $plug->processSvnUpdateTimeline($params); + break; } } @@ -232,4 +235,27 @@ class IDF_Plugin_SyncSvn file_put_contents($authz_file, $fcontent, LOCK_EX); return true; } + + /** + * Update the timeline in post commit. + * + */ + public function processSvnUpdateTimeline($params) + { + $repo_dir = $params['repo_dir']; + $elts = preg_split('#/#', $repo_dir, -1, PREG_SPLIT_NO_EMPTY); + $pname = array_pop($elts); + try { + $project = IDF_Project::getOr404($pname); + } catch (Pluf_HTTP_Error404 $e) { + Pluf_Log::event(array('IDF_Plugin_SyncSvn::processSvnUpdateTimeline', 'Project not found.', array($pname, $params))); + return false; // Project not found + } + // Now we have the project and can update the timeline + Pluf_Log::debug(array('IDF_Plugin_SyncGit::processSvnUpdateTimeline', 'Project found', $pname, $project->id)); + IDF_Scm::syncTimeline($project, true); + Pluf_Log::event(array('IDF_Plugin_SyncGit::processSvnUpdateTimeline', 'sync', array($pname, $project->id))); + + + } } diff --git a/src/IDF/relations.php b/src/IDF/relations.php index 1d7b979..68c5b04 100644 --- a/src/IDF/relations.php +++ b/src/IDF/relations.php @@ -57,6 +57,9 @@ Pluf_Signal::connect('Pluf_User::passwordUpdated', array('IDF_Plugin_SyncSvn', 'entry')); Pluf_Signal::connect('IDF_Project::preDelete', array('IDF_Plugin_SyncSvn', 'entry')); +Pluf_Signal::connect('svnpostcommit.php::run', + array('IDF_Plugin_SyncSvn', 'entry')); + # # Mercurial synchronization Pluf_Signal::connect('IDF_Project::membershipsUpdated', @@ -76,5 +79,8 @@ Pluf_Signal::connect('IDF_Project::created', array('IDF_Plugin_SyncGit', 'entry')); Pluf_Signal::connect('IDF_Key::preDelete', array('IDF_Plugin_SyncGit', 'entry')); +Pluf_Signal::connect('gitpostupdate.php::run', + array('IDF_Plugin_SyncGit', 'entry')); + return $m;