-
Notifications
You must be signed in to change notification settings - Fork 5
/
.danger.php
35 lines (29 loc) · 969 Bytes
/
.danger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php declare(strict_types=1);
use Danger\Config;
use Danger\Context;
use Danger\Rule\CommitRegex;
use Danger\Struct\File;
return (new Config())
->useRule(new CommitRegex('/^(feat|ci|fix|docs|perf|refactor|compat|chore)(\(.+\))?\:\s(.{3,})/m'))
->useRule(static function (Context $context): void {
$prFiles = $context
->platform
->pullRequest
->getFiles()
;
$files = $prFiles
->matches('src/Rule/*')
->filterStatus(File::STATUS_ADDED)
;
if ($files->count() && !$prFiles->has('docs/builtin-rules.md')) {
$context->failure('You have added a new rule. Please change the docs too.');
}
})
->after(static function (Context $context): void {
if ($context->hasFailures()) {
$context->platform->addLabels('Incomplete');
return;
}
$context->platform->removeLabels('Incomplete');
})
;