protected function validate(RuleBook $ruleBook, Repository $repository, IO $io) : void
    {
        // if this is a merge commit skip enforcing message rules
        if ($repository->isMerging()) {
            return;
        }

        $problems = $ruleBook->validate($repository->getCommitMsg());

        if (count($problems)) {
            $io->writeError($this->getErrorOutput($problems, $repository));
            throw new ActionFailed('Commit message validation failed');
        }
        $io->write('<info>All rules passed</info>');
    }