/** * exclude self project, "git" found target project */ private function changeCurrentDirectory() { $result = false; if ($this->config->getProjectDir()) { echo "Change local dir: {$this->config->getProjectDir()}\n"; $result = chdir($this->config->getProjectDir()); } return $result; }
/** * @param string $fileName * @param string $sourcePath * @param boolean $secondary If this is true then file will not put secondary * @return boolean */ public function putFile($fileName, $sourcePath, $secondary = false) { $txtExtensions = ['txt', 'php', 'js', 'css', 'less', 'html', 'xml']; $ext = substr($fileName, strrpos($fileName, '.') + 1); $mode = in_array($ext, $txtExtensions) ? FTP_ASCII : FTP_BINARY; $putResult = ftp_put($this->connection, $fileName, $sourcePath, $mode); if (!$putResult && !$secondary) { // try to create a directory $directories = explode('/', $fileName); $config = \gracerpro\gitdeploy\Config::getInstance(); $dir = $config->getValue('ftp.chdir') === '/' ? '' : $config->getValue('ftp.chdir'); for ($i = 0; $i < count($directories) - 1; ++$i) { $dir .= '/' . $directories[$i]; $mkdirResult = ftp_mkdir($this->connection, $dir); if ($mkdirResult) { echo "Create remote directory: {$dir}\n"; } } // secondary put a file $putResult = $this->putFile($fileName, $sourcePath, true); } return $putResult; }
/** * @return string */ protected function gitGetDiffNameStatus() { $config = \gracerpro\gitdeploy\Config::getInstance(); $diffMode = $config->getGitDiff(); if (empty($diffMode)) { $diffMode = 'origin/master master'; } $params = 'diff ' . $diffMode . ' --name-status'; $command = $this->getGitCommand() . ' ' . $params; echo $command, "\n"; $ret = $this->executeCommand($command); return $ret[0]; }