protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     $showFullPath = $input->getOption(self::OPTION_SHOW_FULL_PATHS);
     // Available tools
     $tools = ['jsonlint', 'phpcs', 'phpcbf'];
     $output->writeln('<info>Available tools</info>:');
     $missingTools = false;
     foreach ($tools as $tool) {
         if (!file_exists($this->projectBasepath . '/bin/' . $tool)) {
             $output->writeln($tool . ' ' . Constants::CHARACTER_KO);
             $missingTools = true;
         } else {
             $output->writeln($tool . ' ' . Constants::CHARACTER_OK);
         }
     }
     if ($missingTools) {
         $output->writeln('<fg=red>Some tools are missing. Did you forget to execute composer install?</fg=red>');
     }
     // Project basepath
     $output->writeln('<info>Project basepath</info>:');
     $output->writeln($this->projectBasepath);
     // Hooks path
     $hooksPath = GitHelper::getHooksPath();
     $output->writeln('<info>Hooks path</info>:');
     $output->writeln($hooksPath);
     // Hooks source path
     $hooksSourcePath = GitHelper::getHooksSourcePath();
     $output->writeln('<info>Hooks source path</info>:');
     $output->writeln($hooksSourcePath);
     // Commited files
     $commitedFiles = (new ExtractCommitedFiles())->getFiles();
     $output->writeln('<info>Commited files</info>:');
     foreach ($this->prefixFiles($commitedFiles, $showFullPath) as $file) {
         $output->writeln($file);
     }
     // Excluded paths
     $output->writeln('<info>Excluded paths</info>:');
     foreach ($this->prefixFiles($this->excludedPaths, $showFullPath) as $path) {
         $output->writeln($path);
     }
     // Project files (not in excluded paths)
     $projectFiles = $this->getAllFiles();
     $output->writeln('<info>Project files</info>:');
     foreach ($this->prefixFiles($projectFiles, $showFullPath) as $file) {
         $output->writeln($file);
     }
 }
Ejemplo n.º 2
0
 /**
  * Project constructor.
  * @param string $basepath @optional
  */
 public function __construct($basepath = null)
 {
     $this->basepath = $basepath === null ? GitHelper::getProjectBasepath() : $basepath;
 }
 public function testHookCheckExceptions()
 {
     $hookManager = new HookManager($this->basePath->getChild('project')->url(), GitHelper::getHooksSourcePath(), 'foo');
     $this->setExpectedException('Exception', '', HookManager::BAD_HOOKS_DESTINATION_PATH_EXCEPTION_CODE);
     $hookManager->checkHooks();
 }
Ejemplo n.º 4
0
 /**
  * @param $projectBasePath
  * @return HookManager
  */
 public static function getDefaultInstance($projectBasePath)
 {
     return new self($projectBasePath, GitHelper::getHooksSourcePath(), GitHelper::getHooksPath());
 }