protected function execute(InputInterface $input, OutputInterface $output) { $configHelper = $this->getHelper('configuration'); /* @var $configHelper GlobalConfigurationHelper */ $repositoryConfig = $configHelper->getConfiguration()->getRepositoryConfiguration($input->getArgument('repository')); $output->writeln(sprintf('Private key file: <info>%s</info>', $repositoryConfig->getIdentityFile())); $output->writeln(sprintf('Ssh alias: <comment>%s</comment>', $repositoryConfig->getSshAlias()), OutputInterface::VERBOSITY_VERBOSE); try { $output->writeln(sprintf('Fingerprint: <comment>%s</comment>', $repositoryConfig->getSshFingerprint())); $output->write(FsUtil::file_get_contents($repositoryConfig->getIdentityFile() . '.pub'), false, OutputInterface::OUTPUT_RAW | OutputInterface::VERBOSITY_QUIET); } finally { $output->writeln(sprintf('Status: %s', $repositoryConfig->getStatusMessage())); } }
private function getBuildCommit() { $commit = '@git-commit@'; if ($commit !== '@' . 'git-commit' . '@') { return $commit; } try { // try to locate composers' installed.json file. (in case of global install) $packages = json_decode(FsUtil::file_get_contents(__DIR__ . '/../../../composer/installed.json'), true); foreach ($packages as $package) { if ($package['name'] === self::PACKAGE_NAME) { return $package['source']['reference']; } } } catch (FilesystemOperationFailedException $ex) { // no op } return 'UNKNOWN'; }
protected function execute(InputInterface $input, OutputInterface $output) { $configHelper = $this->getHelper('configuration'); /* @var $configHelper GlobalConfigurationHelper */ $clicDir = $input->getOption('clic-dir'); if (!$clicDir) { $clicDir = $configHelper->getConfiguration()->getClicDirectory(); } $backupFile = new \SplFileInfo($clicDir . '/settings-backup/' . sha1($configHelper->getConfigurationFile()->getPathname()) . '/' . $input->getArgument('version')); if (!$backupFile->isFile()) { throw new NotAFileException($backupFile); } try { $config = new GlobalConfiguration($backupFile); $config->getConfig(); } catch (\Exception $ex) { $output->writeln(sprintf('<error>Cannot restore %s: %s</error>', $backupFile, $ex->getMessage())); return 1; } FsUtil::file_put_contents($configHelper->getConfigurationFile(), FsUtil::file_get_contents($backupFile)); $output->writeln(sprintf('Restored %s to version %s', $configHelper->getConfigurationFile(), $backupFile->getRealPath())); }