function it_outputs_the_command_when_run_very_very_verbose(GrumPHP $config, ExternalCommand $externalCommandLocator, IOInterface $io) { $io->isVeryVerbose()->willReturn(true); $command = '/usr/bin/grumphp'; $io->write(PHP_EOL . 'Command: ' . ProcessUtils::escapeArgument($command), true)->shouldBeCalled(); $arguments = new ProcessArgumentsCollection([$command]); $process = $this->buildProcess($arguments); }
/** * @param Process $process * * @return string */ public function format(Process $process) { $output = $process->getOutput(); if (!$output) { return $process->getErrorOutput(); } if (!$this->IO->isDecorated()) { return $output; } return $this->formatOutput($output); }
/** * @return void */ private function doPopStash() { if (!$this->stashIsApplied) { return; } try { $this->io->write('<fg=yellow>Reapplying unstaged changes from stash.</fg=yellow>'); $this->repository->run('stash', array('pop', '--quiet')); } catch (Exception $e) { throw new RuntimeException('The stashed changes could not be applied. Please run `git stash pop` manually!' . 'More info: ' . $e->__toString(), 0, $e); } $this->stashIsApplied = false; }
/** * {@inheritdoc} */ public function run(ContextInterface $context) { $config = $this->getConfiguration(); $files = $context->getFiles()->extensions($config['triggered_by']); if (0 === count($files) || empty($config['keywords'])) { return TaskResult::createSkipped($this, $context); } $arguments = $this->processBuilder->createArgumentsForCommand('git'); $arguments->add('grep'); $arguments->add('--cached'); $arguments->add('-n'); $arguments->add('--break'); $arguments->add('--heading'); $arguments->addOptionalArgument('--color', $this->IO->isDecorated()); $arguments->addArgumentArrayWithSeparatedValue('-e', $config['keywords']); $arguments->addFiles($files); $process = $this->processBuilder->buildProcess($arguments); $process->run(); if ($process->isSuccessful()) { return TaskResult::createFailed($this, $context, sprintf('You have blacklisted keywords in your commit:%s%s', PHP_EOL, $this->formatter->format($process))); } return TaskResult::createPassed($this, $context); }
/** * @param Process $process */ private function logProcessInVerboseMode(Process $process) { if ($this->io->isVeryVerbose()) { $this->io->write(PHP_EOL . 'Command: ' . $process->getCommandLine(), true); } }