Ejemplo n.º 1
0
 public static function getServers($config_file)
 {
     $servers = @parse_ini_file($config_file, true);
     $return = array();
     if (!$servers) {
         Helpers::error("File '{$config_file}' is not a valid .ini file.");
     } else {
         foreach ($servers as $uri => $options) {
             if (stristr($uri, "://") !== false) {
                 $options = array_merge($options, parse_url($uri));
             }
             # Throw in some default values, in case they're not set.
             $options = array_merge(array('skip' => false, 'scheme' => 'ftp', 'host' => '', 'user' => '', 'branch' => null, 'port' => 21, 'path' => '/', 'passive' => true, 'clean_directories' => array(), 'ignore_files' => array(), 'ignore_directories' => array(), 'upload_untracked' => array()), $options);
             if (!isset($options['pass']) && !isset($options['sftp_key'])) {
                 $options['pass'] = self::promptPassword();
             }
             if (isset($options['sftp_key'])) {
                 if (substr($options['sftp_key'], 0, 2) == "~/") {
                     $options['sftp_key'] = $_SERVER['HOME'] . substr($options['sftp_key'], 1);
                 }
             }
             if ($options['skip']) {
                 continue;
             } else {
                 unset($options['skip']);
                 $type = "Brunodebarros\\Gitdeploy\\" . ucfirst(strtolower($options['scheme']));
                 $return[$uri] = new $type($options, $config_file);
             }
         }
     }
     return $return;
 }
Ejemplo n.º 2
0
 protected function exec($command, $suffix = "")
 {
     if (chdir($this->repo_path)) {
         $console = trim(shell_exec(self::$git_executable_path . " " . $command . " 2>&1 " . $suffix));
         return $console;
     } else {
         Helpers::error("Unable to access the git repository's folder.");
     }
 }
Ejemplo n.º 3
0
 public function unset_file($file)
 {
     $this->connect();
     $this->recursive_remove($file, false);
     Helpers::logmessage("Deleted: {$file}");
 }
Ejemplo n.º 4
0
 public static function println($msg)
 {
     Helpers::logmessage($msg);
 }
Ejemplo n.º 5
0
 public static function log($msg)
 {
     parent::logmessage($msg);
 }
Ejemplo n.º 6
0
 protected function set_current_commit($target_commit, $list_only = false)
 {
     if (!$list_only) {
         $this->set_file('REVISION', $target_commit);
         $this->set_file('PREVIOUS_REVISION', empty($this->current_commit) ? $target_commit : $this->current_commit);
     }
     if (isset($this->server['maintenance_file'])) {
         $this->set_file($this->server['maintenance_file'], $this->server['maintenance_off_value']);
         Helpers::logmessage("Turned maintenance mode off.");
     }
     Helpers::logmessage("Finished working on: {$this->host}");
     $this->disconnect();
 }