Gush\Helper\ProcessHelper::runCommands PHP Method

runCommands() public method

Run a series of shell command through a Process.
public runCommands ( array $commands )
$commands array
    public function runCommands(array $commands)
    {
        $output = $this->output;
        $callback = function ($type, $buffer) use($output) {
            if (Process::ERR === $type) {
                $output->write('<info>OUT</info> ' . $buffer);
            } else {
                $output->write('<comment>OUT</comment> ' . $buffer);
            }
        };
        foreach ($commands as $command) {
            $this->runCommand($command['line'], $command['allow_failures'], $callback);
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param string $base          The base branch name
  * @param string $sourceBranch  The source branch name
  * @param string $commitMessage Commit message to use for the merge-commit
  * @param bool   $fastForward   Perform merge using fast-forward (default false)
  *
  * @throws WorkingTreeIsNotReady
  *
  * @return null|string The merge-commit hash or null when fast-forward was used
  */
 public function mergeBranch($base, $sourceBranch, $commitMessage, $fastForward = false)
 {
     $this->guardWorkingTreeReady();
     $this->stashBranchName();
     $this->checkout($base);
     if ($fastForward) {
         $this->processHelper->runCommand(['git', 'merge', '--ff', $sourceBranch]);
         return;
     }
     $tmpName = $this->filesystemHelper->newTempFilename();
     file_put_contents($tmpName, $commitMessage);
     $this->processHelper->runCommands([['line' => ['git', 'merge', '--no-ff', '--no-commit', '--no-log', $sourceBranch], 'allow_failures' => false], ['line' => ['git', 'commit', '-F', $tmpName], 'allow_failures' => false]]);
     return trim($this->processHelper->runCommand('git rev-parse HEAD'));
 }