本文整理汇总了PHP中GrumPHP\Task\Context\ContextInterface::getCommitMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP ContextInterface::getCommitMessage方法的具体用法?PHP ContextInterface::getCommitMessage怎么用?PHP ContextInterface::getCommitMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrumPHP\Task\Context\ContextInterface
的用法示例。
在下文中一共展示了ContextInterface::getCommitMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @param ContextInterface|GitCommitMsgContext $context
*/
public function run(ContextInterface $context)
{
$config = $this->getConfiguration();
$commitMessage = $context->getCommitMessage();
$exceptions = [];
foreach ($config['matchers'] as $rule) {
try {
$this->runMatcher($config, $commitMessage, $rule);
} catch (RuntimeException $e) {
$exceptions[] = $e->getMessage();
}
}
if (count($exceptions)) {
return TaskResult::createFailed($this, $context, implode(PHP_EOL, $exceptions));
}
return TaskResult::createPassed($this, $context);
}
示例2: run
/**
* @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));
}
}
}
示例3: run
/**
* @param ContextInterface|GitCommitMsgContext $context
*/
public function run(ContextInterface $context)
{
$config = $this->getConfiguration();
$commitMessage = $context->getCommitMessage();
foreach ($config['matchers'] as $rule) {
$expression = Expression::create($rule);
$regex = $expression->getRegex();
if ((bool) $config['case_insensitive']) {
$regex->addOption('i');
}
if ((bool) $config['multiline']) {
$regex->addOption('m');
}
if (!preg_match($regex->render(), $commitMessage)) {
throw new RuntimeException(sprintf('The commit message does not match the rule: %s', $rule));
}
}
}