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; }
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."); } }
public function unset_file($file) { $this->connect(); $this->recursive_remove($file, false); Helpers::logmessage("Deleted: {$file}"); }
public static function println($msg) { Helpers::logmessage($msg); }
public static function log($msg) { parent::logmessage($msg); }
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(); }