/** * @param array $args * * @return Response */ public function run(array $args) { $this->lastRequest = new Request(); $this->lastRequest->setCwd($this->path); $this->lastRequest->setCommand(Git::getGitCommand() . ' ' . implode(' ', $args)); // var_dump($this->lastRequest); return $this->getExecutor()->run($this->lastRequest); }
public function run(Request $request) { $this->runDate = new DateTime(); $descriptorspec = [1 => ["pipe", "w"], 2 => ["pipe", "w"]]; $process = proc_open($request->getCommand(), $descriptorspec, $pipes, $request->getCwd()); if (!is_resource($process)) { throw new ExecuteCommandException('Execute error!'); } $out = trim(stream_get_contents($pipes[1])); fclose($pipes[1]); $error = trim(stream_get_contents($pipes[2])); fclose($pipes[2]); $exitCode = proc_close($process); $valid = $exitCode === 0; return new Response(['out' => $out, 'error' => $error, 'valid' => $valid, 'exitCode' => $exitCode, 'command' => $request->getCommand(), 'runDate' => $this->runDate, 'cwd' => $request->getCwd()]); }