Runs a Git command on the repository.

@param string $command The command.

@return string The trimmed output from the command.

@throws RuntimeException If the command failed.
16960
private function runGitCommand($command)
    {
        $path = dirname($this->file);
        $process = new Process($command, $path);

        if (0 === $process->run()) {
            return trim($process->getOutput());
        }

        throw new RuntimeException(
            sprintf(
                'The tag or commit hash could not be retrieved from "%s": %s',
                $path,
                $process->getErrorOutput()
            )
        );
    }
1013684
protected function runCommand($command)
    {
        $process = $this->getProcess();

        $process->setCommandLine(trim($this->find() . ' ' . $command));

        $process->run();

        return $this;
    }
164
public function git($commandString)
    {
        // clean commands that begin with "git "
        $commandString = preg_replace('/^git\s/', '', $commandString);

        $commandString = $this->options['git_executable'].' '.$commandString;

        $command = new $this->options['command_class']($this->dir, $commandString, $this->debug);

        return $command->run();
    }
292959
public function dispatchToQueue($command)
    {
        $connection = $command->connection ?? null;

        $queue = call_user_func($this->queueResolver, $connection);

        if (! $queue instanceof Queue) {
            throw new RuntimeException('Queue resolver did not return a Queue implementation.');
        }

        if (method_exists($command, 'queue')) {
            return $command->queue($queue, $command);
        }

        return $this->pushCommandToQueue($queue, $command);
    }
975954
private function run($command)
    {
        $application = $this->createApplication();
        $application->setAutoExit(false);

        $this->applicationTester = new ApplicationTester($application);

        $this->outputFile = tempnam('.', 'phpeg');

        return $this->applicationTester->run(array(
            'command' => $command,
            'input-file' => $this->inputFile,
            'output-file' => $this->outputFile
        ));
    }
1024578
protected function run()
    {
        $process = $this->buildProcess();

        if ($this->output !== null) {
            throw new GitException(
                'Command cannot be executed twice',
                $process->getWorkingDirectory(),
                $process->getCommandLine(),
                $this->output,
                ''
            );
        }

        $this->repository->getConfig()->getLogger()->debug(
            \sprintf('[ccabs-repository-git] exec [%s] %s', $this->workingDirectory, $process->getCommandLine())
        );

        if ($this->dryRun) {
            return $process->getCommandLine();
        }

        $process->run();
        $this->output = $process->getOutput();
        $this->output = \rtrim($this->output, "\r\n");

        if (!$process->isSuccessful()) {
            throw GitException::createFromProcess('Could not execute git command', $process);
        }

        return $this->output;
    }
1020056
public function execute($command) {
    /** @var \Robo\Common\ProcessExecutor $process_executor */
    $process_executor = Robo::process(new Process($command));
    return $process_executor->dir($this->getConfigValue('repo.root'))
      ->printOutput(FALSE)
      ->printMetadata(FALSE)
      ->interactive(FALSE);
  }
1349103
public function execute($command)
    {
        exec($command, $result, $returnValue);

        if ($returnValue === 0) {
            return $result;
        }

        throw new \RuntimeException(sprintf('Failed to execute command: %s', $command), $returnValue);
    }
624776
public function remoteBranchExists($remote, $branch)
    {
        $result = $this->processHelper->runCommand(['git', 'ls-remote', $remote], true);
        if (1 >= ($exists = preg_match_all('#(?<=\s)'.preg_quote('refs/heads/'.$branch, '#').'(?!\w)$#m', $result))) {
            return 1 === $exists;
        }

        throw new \RuntimeException(sprintf('Invalid refs found while searching for remote branch at "refs/heads/%s"', $branch));
    }
551327
public function run(CommandInterface $command)
    {
        $result = null;

        /** @var RunnerInterface $runner */
        foreach($this->runners as $runner) {
            $result = $runner->run($command, $result);
        }

        return $result;
    }
469485
public function fire(Command $command)
    {
        $gitignorePath = base_path('.gitignore');

        if (! $this->gitignoreContainsComposerLock($gitignorePath)) {
            return;
        }

        $removeComposerLock = $command->confirm('Do you want to remove composer.lock from .gitignore ?', true);
        if ($removeComposerLock) {
            $out = $this->getGitignoreLinesButComposerLock($gitignorePath);
            $this->writeNewGitignore($gitignorePath, $out);
        }
    }
242411
protected function executeCommand($command)
    {

        try {
            CliExecutor::executeCommand($command);
        } catch (Exception $e) {
            exit($e->getMessage() . PHP_EOL . $e->getTraceAsString() . PHP_EOL);
        }
    }
1356319
public function exec($command)
    {
        // Check for prohibited commands
        foreach ($this->prohibitedCommands as $prohibitedCommand) {
            if (strpos(trim($command), $prohibitedCommand) !== false) {
                throw new \Exception('The shell command ' . $command . ' is prohibited');
            }
        }
        return exec($command);
    }
260875
private static function runCommand($command)
    {
        if (!function_exists('proc_open')) {
            return null;
        }

        $descriptorSpec = [
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
        ];
        $process = proc_open($command, $descriptorSpec, $pipes, null, null, ['suppress_errors' => true]);
        if (!is_resource($process)) {
            return null;
        }

        $info = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        fclose($pipes[2]);
        proc_close($process);

        return $info;
    }
1055800
public function runAsProcessReturningProcessObject(string $command) : Process
    {
        $process = new Process($command);
        $process->run();
        $process->setTimeout(null);
        $process->setIdleTimeout(60);
        $process->wait();

        return $process;
    }
1308335
public function cloneRepository($remote)
    {
        $fileSystem = new Filesystem();
        $fileSystem->mkdir($this->directory);

        if ($fileSystem->exists($this->directory.DIRECTORY_SEPARATOR.'.git')) {
            throw new \RuntimeException(sprintf('"%s" already is a git repository.', $this->directory));
        }

        return $this->executeCmd(sprintf(
            self::CMD_GITCLONE,
            $remote,
            $this->directory
        ));
    }
76243
protected function execute($command)
    {
        $process = new Process($command, null, null, null, $this->timeout);
        $process->run();

        if (!$process->isSuccessful()) {
            throw new \RuntimeException($process->getErrorOutput());
        }
    }