protected function execute(InputInterface $input, OutputInterface $output) { $range = $input->getArgument('range') ?: (isset($_SERVER['TRAVIS_COMMIT_RANGE']) ? $_SERVER['TRAVIS_COMMIT_RANGE'] : ''); if (!$range) { throw new \RuntimeException("No git range given via argument or TRAVIS_COMMIT_RANGE environment variable."); } exec('git diff --name-only ' . escapeshellarg($range), $result); $build = new Build(new ConsoleIO($input, $output, $this->getHelperSet())); $this->packages = $build->loadPackages(getcwd()); $changePackageName = rtrim($input->getArgument('package'), '/'); $this->calculateDependencies($changePackageName); if ($output->isVerbose()) { $output->writeln('Checking for changes in the following directories:'); foreach ($this->checkPaths as $checkPath) { $output->writeln('- ' . $checkPath); } $output->writeln(sprintf('Iterating the changed files in git commit range %s', $range)); } $found = false; foreach ($result as $changedFile) { if ($output->isVerbose()) { $output->writeln(sprintf("- %s", $changedFile)); } foreach ($this->checkPaths as $checkPath) { if (strpos(trim($changedFile), $checkPath) !== false) { if ($output->isVerbose()) { $output->writeln(sprintf(' Matches check path %s', $checkPath)); } $found = true; } } } exit($found ? 0 : 1); }
public function testLoadPackagesComposerExampleProject() { $build = new Build(); $packages = $build->loadPackages(__DIR__ . '/../_fixtures/example-composer'); $packageNames = array_keys($packages); $this->assertEquals(array('vendor/foo/bar', 'vendor/foo/baz'), $packageNames); }