protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Welcome
        $output->writeln(
            '<info>Welcome to the Cypress GitElephantBundle merge command.</info>'
        );
        if ($input->getOption('no-push')) {
            $output->writeln(
                '<comment>--no-push option enabled (this option disable push destination branch to remotes)</comment>'
            );
        }

        /** @var GitElephantRepositoryCollection $rc */
        $rc = $this->getContainer()->get('git_repositories');

        if ($rc->count() == 0) {
            throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');
        }

        /** @var Repository $repository */
        foreach ($rc as $key => $repository) {
            if ($key == 0 || $key > 0 && $input->getOption('all')) {
                /** @var Branch $source */
                $source = $repository->getBranch($input->getArgument('source'));
                if (is_null($source)) {
                    throw new \Exception('Source branch ' . $input->getArgument('source') . ' doesn\'t exists');
                }
                /** @var Branch $destination */
                $destination = $repository->getBranch($input->getArgument('destination'));
                if (is_null($destination)) {
                    throw new \Exception('Destination branch ' . $input->getArgument('destination') . ' doesn\'t exists');
                }
                $repository->checkout($destination->getName());
                $repository->merge($source, '', (!$input->getOption('fast-forward') ? 'no-ff' : 'ff-only'));
                if (!$input->getOption('no-push')) {
                    /** @var Remote $remote */
                    foreach ($repository->getRemotes() as $remote) {
                        $repository->push($remote->getName(), $repository->getMainBranch()->getName()); // Push destination branch to all remotes
                    }
                }
                $repository->checkout($input->getArgument('source'));
                $output->writeln('Merge from ' . $input->getArgument('source') . ' branch to ' . $input->getArgument('destination') . ' done' . (!$input->getOption('no-push') ? ' and pushed to all remotes.' : ''));
            }
        }
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Welcome
        $output->writeln(
            '<info>Welcome to the Cypress GitElephantBundle merge command.</info>'
        );
        if ($input->getOption('no-push')) {
            $output->writeln(
                '<comment>--no-push option enabled (this option disable push destination branch to remotes)</comment>'
            );
        }

        /** @var GitElephantRepositoryCollection $rc */
        $rc = $this->getContainer()->get('git_repositories');

        if ($rc->count() == 0) {
            throw new \Exception('Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use');
        }

        /** @var Repository $repository */
        foreach ($rc as $key => $repository) {
            if ($key == 0 || $key > 0 && $input->getOption('all')) {
                /** @var Branch $source */
                $source = $repository->getBranch($input->getArgument('source'));
                if (is_null($source)) {
                    throw new \Exception('Source branch ' . $input->getArgument('source') . ' doesn\'t exists');
                }
                /** @var Branch $destination */
                $destination = $repository->getBranch($input->getArgument('destination'));
                if (is_null($destination)) {
                    throw new \Exception('Destination branch ' . $input->getArgument('destination') . ' doesn\'t exists');
                }
                $repository->checkout($destination->getName());
                $repository->merge($source, '', (!$input->getOption('fast-forward') ? 'no-ff' : 'ff-only'));
                if (!$input->getOption('no-push')) {
                    /** @var Remote $remote */
                    foreach ($repository->getRemotes() as $remote) {
                        $repository->push($remote->getName(), $repository->getMainBranch()->getName()); // Push destination branch to all remotes
                    }
                }
                $repository->checkout($input->getArgument('source'));
                $output->writeln('Merge from ' . $input->getArgument('source') . ' branch to ' . $input->getArgument('destination') . ' done' . (!$input->getOption('no-push') ? ' and pushed to all remotes.' : ''));
            }
        }
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) { // Welcome $ output -> writeln ( '<info>Welcome to the Cypress GitElephantBundle merge command.</info>' ) ; if ( $ input -> getOption ( 'no-push' ) ) { $ output -> writeln ( '<comment>--no-push option enabled (this option disable push destination branch to remotes)</comment>' ) ; } /** @var GitElephantRepositoryCollection $rc */ $ rc = $ this -> getContainer ( ) -> get ( 'git_repositories' ) ; if ( $ rc -> count ( ) == 0 ) { throw new \ Exception ( 'Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use' ) ; } /** @var Repository $repository */ foreach ( $ rc as $ key => $ repository ) { if ( $ key == 0 || $ key > 0 && $ input -> getOption ( 'all' ) ) { /** @var Branch $source */ $ source = $ repository -> getBranch ( $ input -> getArgument ( 'source' ) ) ; if ( is_null ( $ source ) ) { throw new \ Exception ( 'Source branch ' . $ input -> getArgument ( 'source' ) . ' doesn\'t exists' ) ; } /** @var Branch $destination */ $ destination = $ repository -> getBranch ( $ input -> getArgument ( 'destination' ) ) ; if ( is_null ( $ destination ) ) { throw new \ Exception ( 'Destination branch ' . $ input -> getArgument ( 'destination' ) . ' doesn\'t exists' ) ; } $ repository -> checkout ( $ destination -> getName ( ) ) ; $ repository -> merge ( $ source , '' , ( ! $ input -> getOption ( 'fast-forward' ) ? 'no-ff' : 'ff-only' ) ) ; if ( ! $ input -> getOption ( 'no-push' ) ) { /** @var Remote $remote */ foreach ( $ repository -> getRemotes ( ) as $ remote ) { $ repository -> push ( $ remote -> getName ( ) , $ repository -> getMainBranch ( ) -> getName ( ) ) ; // Push destination branch to all remotes } } $ repository -> checkout ( $ input -> getArgument ( 'source' ) ) ; $ output -> writeln ( 'Merge from ' . $ input -> getArgument ( 'source' ) . ' branch to ' . $ input -> getArgument ( 'destination' ) . ' done' . ( ! $ input -> getOption ( 'no-push' ) ? ' and pushed to all remotes.' : '' ) ) ; } } }
Execute merge command

@param InputInterface  $input
@param OutputInterface $output

@throws \Exception
@return int|null|void
Execute merge command