Example #1
0
 public static function update($projectDir, $options = array())
 {
     $actionLog = self::initAction('update', $projectDir, 'SvnAction', $options);
     $configDirectory = '';
     if (is_null($projectDir)) {
         $actionLog->error(sprintf(__('Forbidden NULL value for input parameter [%s]', true), $projectDir));
     } else {
         if (!is_dir($projectDir)) {
             $actionLog->error(sprintf(__('Directory %s not found', true), $projectDir));
         } else {
             if (!is_dir($projectDir . DS . '.svn')) {
                 $actionLog->error(sprintf(__('Specified directory %s is not a working copy', true), $projectDir . DS . '.svn'));
             } else {
                 if (!is_writeable($projectDir)) {
                     $actionLog->error(sprintf(__('Specified directory %s is not writeable', true), $projectDir));
                 }
             }
         }
     }
     // Define step options
     $default_options = array('revision' => null, 'configDirectory' => null, 'parseResponse' => false);
     $options = array_merge($default_options, $options);
     // Execute command
     $projectDir = Utils::formatPath($projectDir);
     $revision = $options['revision'] != null ? ' -r' . $options['revision'] : '';
     $authentication = '';
     if (!is_null($options['user_svn'])) {
         $authentication .= '--username ' . $options['user_svn'];
         if (!empty($options['password_svn'])) {
             $authentication .= ' --password ' . $options['password_svn'];
         }
     }
     if (!is_null($options['configDirectory'])) {
         $configDirectory = '--config-dir ' . Utils::formatPath($options['configDirectory']);
     }
     $command = "svn update --non-interactive {$configDirectory} {$revision} {$authentication} 2>&1";
     $commandForLog = "svn update --non-interactive {$configDirectory} {$revision} XXXX 2>&1";
     ShellAction::executeCommand($command, array('directory' => $projectDir, 'actionLog' => $actionLog, 'commandForLog' => $commandForLog));
     // Parse response
     if (!(strpos($actionLog->getResult(), 'PROPFIND request failed on') === false) && $options['parseResponse']) {
         $actionLog->error(__('An error has been detected in the SVN output', true));
     }
     // End action
     $actionLog->end();
     return $actionLog;
 }
Example #2
0
 private function _resetPermissions()
 {
     // Check input parameters
     if (!$this->isInitialized()) {
         $this->_stepLog->error(sprintf(__('Missing working data', true)));
     }
     $path = $this->_project['Project']['prd_path'];
     $mode = Configure::read('FileSystem.permissions.files');
     // Default permissions
     ShellAction::changePermissions($path, $mode, array('stepLog' => $this->_stepLog));
     // Writable permissions
     self::_loadConfig();
     if (isset($this->_config->writable) && is_array($this->_config->writable)) {
         foreach ($this->_config->writable as $subPath) {
             ShellAction::changePermissions($path . $subPath, array('dir' => Configure::read('FileSystem.permissions.writable')), array('stepLog' => $this->_stepLog));
         }
     }
 }