コード例 #1
0
ファイル: SyncSvn.php プロジェクト: burbuja/indefero
 /**
  * Run svnadmin command to create the corresponding Subversion
  * repository.
  *
  * @param IDF_Project 
  * @return bool Success
  */
 function processSvnCreate($project)
 {
     if ($project->getConf()->getVal('scm') != 'svn') {
         return false;
     }
     $shortname = $project->shortname;
     if (false === ($svn_path = Pluf::f('idf_plugin_syncsvn_svn_path', false))) {
         throw new Pluf_Exception_SettingError("'idf_plugin_syncsvn_svn_path' must be defined in your configuration file.");
     }
     if (file_exists($svn_path . '/' . $shortname)) {
         throw new Exception(sprintf(__('The repository %s already exists.'), $svn_path . '/' . $shortname));
     }
     $return = 0;
     $output = array();
     $cmd = sprintf(Pluf::f('svnadmin_path', 'svnadmin') . ' create %s', escapeshellarg($svn_path . '/' . $shortname));
     $cmd = Pluf::f('idf_exec_cmd_prefix', '') . $cmd;
     $ll = exec($cmd, $output, $return);
     if ($return != 0) {
         Pluf_Log::error(array('IDF_Plugin_SyncSvn::processSvnCreate', 'Error', array('path' => $svn_path . '/' . $shortname, 'output' => $output)));
         return;
     }
     $p = realpath(dirname(__FILE__) . '/../../../scripts/svn-post-commit');
     exec(sprintf(Pluf::f('idf_exec_cmd_prefix', '') . 'ln -s %s %s', escapeshellarg($p), escapeshellarg($svn_path . '/' . $shortname . '/hooks/post-commit')), $out, $res);
     if ($res != 0) {
         Pluf_Log::warn(array('IDF_Plugin_SyncSvn::processSvnCreate', 'post-commit hook creation error.', $svn_path . '/' . $shortname . '/hooks/post-commit'));
         return;
     }
     $p = realpath(dirname(__FILE__) . '/../../../scripts/svn-post-revprop-change');
     exec(sprintf(Pluf::f('idf_exec_cmd_prefix', '') . 'ln -s %s %s', escapeshellarg($p), escapeshellarg($svn_path . '/' . $shortname . '/hooks/post-revprop-change')), $out, $res);
     if ($res != 0) {
         Pluf_Log::warn(array('IDF_Plugin_SyncSvn::processSvnCreate', 'post-revprop-change hook creation error.', $svn_path . '/' . $shortname . '/hooks/post-revprop-change'));
         return;
     }
     return $return == 0;
 }
コード例 #2
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));
 }