예제 #1
0
 /**
  * Entry point for the post-update signal.
  *
  * It tries to find the name of the project, when found it runs an
  * update of the timeline.
  */
 public static function postUpdate($signal, &$params)
 {
     // Chop the ".git" and get what is left
     $pname = basename($params['git_dir'], '.git');
     try {
         $project = IDF_Project::getOr404($pname);
     } catch (Pluf_HTTP_Error404 $e) {
         Pluf_Log::event(array('IDF_Plugin_SyncGit::postUpdate', '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::postUpdate', 'Project found', $pname, $project->id));
     IDF_Scm::syncTimeline($project, true);
     Pluf_Log::event(array('IDF_Plugin_SyncGit::postUpdate', 'sync', array($pname, $project->id)));
 }
예제 #2
0
 /**
  * Update the timeline in post commit.
  *
  */
 public function processSyncTimeline($params)
 {
     $pname = basename($params['rel_dir']);
     try {
         $project = IDF_Project::getOr404($pname);
     } catch (Pluf_HTTP_Error404 $e) {
         Pluf_Log::event(array('IDF_Plugin_SyncMercurial::processSyncTimeline', '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_SyncMercurial::processSyncTimeline', 'Project found', $pname, $project->id));
     IDF_Scm::syncTimeline($project, true);
     Pluf_Log::event(array('IDF_Plugin_SyncMercurial::processSyncTimeline', 'sync', array($pname, $project->id)));
 }
예제 #3
0
/**
 * This script process the queue of items.
 *
 * At the moment the queue is only used for the webhooks, but it would
 * be good in the future to use it for indexing and email
 * notifications.
 *
 */
require dirname(__FILE__) . '/../src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start(dirname(__FILE__) . '/../src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
#;*/ ::
$lock_file = Pluf::f('idf_queuecron_lock', Pluf::f('tmp_folder', '/tmp') . '/queuecron.lock');
if (file_exists($lock_file)) {
    Pluf_Log::event(array('queuecron.php', 'skip'));
    return;
}
file_put_contents($lock_file, time(), LOCK_EX);
/**
 * [signal]
 *
 * queuecron.php::run
 *
 * [sender]
 *
 * queuecron.php
 *
 * [description]
 *
 * This signal allows an application to perform a set of tasks when
예제 #4
0
 /**
  * Update the timeline after a push
  *
  */
 public function processSyncTimeline($project_name)
 {
     try {
         $project = IDF_Project::getOr404($project_name);
     } catch (Pluf_HTTP_Error404 $e) {
         Pluf_Log::event(array('IDF_Plugin_SyncMonotone::processSyncTimeline', 'Project not found.', array($project_name, $params)));
         return false;
         // Project not found
     }
     Pluf_Log::debug(array('IDF_Plugin_SyncMonotone::processSyncTimeline', 'Project found', $project_name, $project->id));
     IDF_Scm::syncTimeline($project, true);
     Pluf_Log::event(array('IDF_Plugin_SyncMonotone::processSyncTimeline', 'sync', array($project_name, $project->id)));
 }
예제 #5
0
파일: Queue.php 프로젝트: burbuja/indefero
 /** 
  * Parse the queue.
  *
  * It is a signal handler to just hook itself at the right time in
  * the cron job performing the maintainance work.
  *
  * The processing relies on the fact that no other processing jobs
  * must run at the same time. That is, your cron job must use a
  * lock file or something like to not run in parallel.
  *
  * The processing is simple, first get 500 queue items, mark them
  * as being processed and for each of them call the processItem()
  * method which will trigger another event for processing.
  *
  * If you are processing more than 500 items per batch, you need
  * to switch to a different solution.
  *
  */
 public static function process($sender, &$params)
 {
     $where = 'status=0 OR status=2';
     $items = Pluf::factory('IDF_Queue')->getList(array('filter' => $where, 'nb' => 500));
     Pluf_Log::event(array('IDF_Queue::process', $items->count()));
     foreach ($items as $item) {
         $item->status = 1;
         $item->update();
     }
     foreach ($items as $item) {
         $item->status = 1;
         $item->processItem();
     }
 }
예제 #6
0
파일: Serve.php 프로젝트: burbuja/indefero
 /**
  * Init a new empty bare repository.
  *
  * @param string Full path to the repository
  */
 public function initRepository($fullpath)
 {
     if (!file_exists($fullpath)) {
         mkdir($fullpath, 0750, true);
     }
     $out = array();
     $res = 0;
     exec(sprintf(Pluf::f('idf_exec_cmd_prefix', '') . Pluf::f('git_path', 'git') . ' --git-dir=%s init', escapeshellarg($fullpath)), $out, $res);
     if ($res != 0) {
         Pluf_Log::error(array('IDF_Plugin_Git_Serve::initRepository', $res, $fullpath));
         throw new Exception(sprintf('Init repository error, exit status %d.', $res));
     }
     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;
     }
     $out = array();
     $res = 0;
     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));
     // Configure the core.quotepath option
     $quotepath = Pluf::f('git_core_quotepath', true) == true ? 'true' : 'false';
     $out = array();
     $res = 0;
     exec(sprintf(Pluf::f('idf_exec_cmd_prefix', '') . Pluf::f('git_path', 'git') . ' config -f %s/config --add core.quotepath %s', escapeshellarg($fullpath), escapeshellarg($quotepath)), $out, $res);
     if ($res != 0) {
         Pluf_Log::warn(array('IDF_Plugin_Git_Serve::initRepository', 'core.quotepath configuration error.', $quotepath));
         return;
     }
     Pluf_Log::debug(array('IDF_Plugin_Git_Serve::initRepository', 'core.quotepath configured.', $quotepath));
 }
예제 #7
0
/**
 * This script will send the notifications after a push in your 
 * repository.
 */
require dirname(__FILE__) . '/../src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start(dirname(__FILE__) . '/../src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
/**
 * [signal]
 *
 * gitpostupdate.php::run
 *
 * [sender]
 *
 * gitpostupdate.php
 *
 * [description]
 *
 * This signal allows an application to perform a set of tasks on a
 * post update of a git repository.
 *
 * [parameters]
 *
 * array('git_dir' => '/path/to/git/repository.git',
 *       'env' => array_merge($_ENV, $_SERVER));
 *
 */
$params = array('git_dir' => $argv[1], 'env' => array_merge($_ENV, $_SERVER));
Pluf_Log::event(array('gitpostupdate.php', 'Send run signal.', $params));
Pluf_Signal::send('gitpostupdate.php::run', 'gitpostupdate.php', $params);
예제 #8
0
 * This script will send the notifications after a push in your 
 * repository.
 */
require dirname(__FILE__) . '/../src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start(dirname(__FILE__) . '/../src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
/**
 * [signal]
 *
 * svnpostcommit.php::run
 *
 * [sender]
 *
 * svnpostcommit.php
 *
 * [description]
 *
 * This signal allows an application to perform a set of tasks on a
 * post commit of a subversion repository.
 *
 * [parameters]
 *
 * array('repo_dir' => '/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_Log::event(array('svnpostcommit.php', 'Send run signal.', $params));
Pluf_Signal::send('svnpostcommit.php::run', 'svnpostcommit.php', $params);