本文整理匯總了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));
}
}
}