Gush\Subscriber\GitRepoSubscriber::initialize PHP Method

initialize() public method

public initialize ( Symfony\Component\Console\Event\ConsoleCommandEvent $event )
$event Symfony\Component\Console\Event\ConsoleCommandEvent
    public function initialize(ConsoleCommandEvent $event)
    {
        /** @var GitRepoFeature|BaseCommand $command */
        $command = $event->getCommand();
        if (!$command instanceof GitRepoFeature) {
            return;
        }
        $input = $event->getInput();
        if (GitHelper::UNDEFINED_ADAPTER === $input->getOption('repo-adapter')) {
            $input->setOption('repo-adapter', $this->detectAdapterName());
        }
        $adapterFactory = $this->application->getAdapterFactory();
        $adapterName = $input->getOption('repo-adapter');
        if ($input->hasOption('issue-adapter') && GitHelper::UNDEFINED_ADAPTER === $input->getOption('issue-adapter') && $adapterFactory->supports($adapterName, AdapterFactory::SUPPORT_ISSUE_TRACKER)) {
            $input->setOption('issue-adapter', $adapterName);
        }
        $this->validateAdaptersConfig($input);
        $adapter = $this->getAdapter($adapterName);
        $org = GitHelper::undefinedToDefault($input->getOption('org'));
        $repo = GitHelper::undefinedToDefault($input->getOption('repo'));
        $this->application->setAdapter($adapter);
        // When no org and/or repo is set, determine this from the git remote,
        // but warn its better to run "core:init" as this autodetection process
        // is much slower!
        if (null === $org || null === $repo) {
            if (!$this->gitHelper->isGitDir()) {
                throw new UserException('Provide the --org and --repo options when your are outside of a Git directory.');
            }
            list($org, $repo) = $this->getRepositoryReference($adapter, $org, $repo);
            $this->styleHelper->note(['You did not set or provided an organization and/or repository name.', 'Gush automatically detected the missing information.', sprintf('Org: "%s" / repo: "%s"', $org, $repo), 'But for future reference and better performance it is advised to run "core:init".']);
        }
        $input->setOption('org', $org);
        $input->setOption('repo', $repo);
        $adapter->setRepository($repo)->setUsername($org);
        if ($command instanceof IssueTrackerRepoFeature) {
            $this->initializeIssueTracker($event, $org, $repo, $adapterName);
        }
    }