forked from jwu910/check-it-out
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dangerfile.js
56 lines (43 loc) · 1.31 KB
/
dangerfile.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { danger, fail, warn } from 'danger';
const pr = danger.github.pr;
const modified = danger.git.modified_files;
const bodyAndTitle = (pr.body + pr.title).toLowerCase();
const trivialPR = bodyAndTitle.includes('#trivial');
const filesOnly = file => file.endsWith('/');
const touchedFiles = modified
.concat(danger.git.created_files)
.filter(p => filesOnly(p));
//No empty assignee
if (!pr.assignee && pr.user.login !== 'jwu910') {
const method = pr.title.includes('WIP') ? warn : fail;
method(
'This pull request needs an assignee, and optionally include any reviewers.',
);
}
//No empty descriptions
if (pr.body.length < 10) {
fail('This pull request needs a description.');
}
//No empty title
if (pr.title.length < 3) {
fail('This pull request needs a title.');
}
//No empty changelog
const changelogChanges = modified.find(f => f === 'CHANGELOG.md');
if (modified > 0 && !trivialPR && !changelogChanges) {
fail('No CHANGELOG added.');
}
//First timers only
if (
pr.author_association === 'FIRST_TIMER' ||
pr.author_association === 'FIRST_TIME_CONTRIBUTOR'
) {
message(
'Thank you for the pull request and congratulations on your first PR to this repo!',
);
}
//Warn renamed files
const renamedFiles = danger.git.renamed_files;
if (renamedFiles) {
warn('Renamed files were found.');
}