protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Welcome
        $output->writeln(
            '<info>Welcome to the Cypress GitElephantBundle commit command.</info>'
        );
        if ($input->getOption('no-push')) {
            $output->writeln(
                '<comment>--no-push option enabled (this option disable push commit 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')) {
                $repository->commit($input->getArgument('message'), !$input->getOption('no-stage-all'));
                if (!$input->getOption('no-push')) {
                    /** @var Remote $remote */
                    foreach ($repository->getRemotes() as $remote) {
                        $repository->push($remote->getName(), $repository->getMainBranch()->getName()); // Push last current branch commit to all remotes
                    }
                }
                $output->writeln('New commit to local repository created ' . $repository->getName() . (!$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 commit command.</info>'
        );
        if ($input->getOption('no-push')) {
            $output->writeln(
                '<comment>--no-push option enabled (this option disable push commit 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')) {
                $repository->commit($input->getArgument('message'), !$input->getOption('no-stage-all'));
                if (!$input->getOption('no-push')) {
                    /** @var Remote $remote */
                    foreach ($repository->getRemotes() as $remote) {
                        $repository->push($remote->getName(), $repository->getMainBranch()->getName()); // Push last current branch commit to all remotes
                    }
                }
                $output->writeln('New commit to local repository created ' . $repository->getName() . (!$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 commit command.</info>' ) ; if ( $ input -> getOption ( 'no-push' ) ) { $ output -> writeln ( '<comment>--no-push option enabled (this option disable push commit 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' ) ) { $ repository -> commit ( $ input -> getArgument ( 'message' ) , ! $ input -> getOption ( 'no-stage-all' ) ) ; if ( ! $ input -> getOption ( 'no-push' ) ) { /** @var Remote $remote */ foreach ( $ repository -> getRemotes ( ) as $ remote ) { $ repository -> push ( $ remote -> getName ( ) , $ repository -> getMainBranch ( ) -> getName ( ) ) ; // Push last current branch commit to all remotes } } $ output -> writeln ( 'New commit to local repository created ' . $ repository -> getName ( ) . ( ! $ input -> getOption ( 'no-push' ) ? ' and pushed to all remotes.' : '' ) ) ; } } }
Execute commit command

@param InputInterface  $input
@param OutputInterface $output

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