/** * @param ContextInterface|GitCommitMsgContext $context */ public function run(ContextInterface $context) { $config = $this->getConfiguration(); $commitMessage = $context->getCommitMessage(); foreach ($config['matchers'] as $rule) { $regex = new Regex($rule); if ((bool) $config['case_insensitive']) { $regex->addPatternModifier('i'); } if ((bool) $config['multiline']) { $regex->addPatternModifier('m'); } if (!preg_match($regex->__toString(), $commitMessage)) { throw new RuntimeException(sprintf('The commit message does not match the rule: %s', $rule)); } } }