コード例 #1
0
ファイル: SyncGit.php プロジェクト: burbuja/indefero
 /**
  * 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
ファイル: SyncMercurial.php プロジェクト: burbuja/indefero
 /**
  * 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
ファイル: SyncMonotone.php プロジェクト: burbuja/indefero
 /**
  * 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)));
 }
コード例 #4
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));
 }
コード例 #5
0
ファイル: Scm.php プロジェクト: Br3nda/indefero
 /**
  * Run shell_exec and log some information.
  *
  * @param $caller Calling method
  * @param $cmd Command to run
  * @return string The output
  */
 public static function shell_exec($caller, $cmd)
 {
     Pluf_Log::stime('timer');
     $ret = shell_exec($cmd);
     Pluf_Log::perf(array($caller, $cmd, Pluf_Log::etime('timer', 'total_exec')));
     Pluf_Log::debug(array($caller, $cmd, $ret));
     Pluf_Log::inc('exec_calls');
     return $ret;
 }