forked from freebsd/freebsd-src
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (52 loc) · 2.07 KB
/
contribute.yml
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
57
58
59
60
# XXX: checklist
name: Contribute
on:
pull_request:
types: [ opened, reopened, edited, synchronize ]
jobs:
checklist:
name: Check List
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
# A Javascript function
script: |
const commits = await github.paginate(github.rest.pulls.listCommits, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
let checklist = {};
const tag = "<!--SomethingUnique-->";
const addToChecklist = (msg, sha) => {
if (!checklist[msg])
checklist[msg] = [];
checklist[msg].push(sha);
}
for (const commit of commits) {
const sob_lines = commit.commit.message.match("/^\s*signed-off-by:./i");
if (sob_lines == null && !commit.commit.author.email.endsWith("FreeBSD.org"))
addToChecklist("Missing Signed-off-by: lines", commit.sha);
else {
for (const line in sob_lines) {
if (!line.startsWith("Signed-off-by:"))
addToChecklist("Expected \"Signed-off-by\", got " + line, commit.sha);
else if (!line.endsWith(" "))
addToChecklist("Space required after Signed-off-by", commit.sha);
}
}
if (commit.commit.author.email.includes("noreply"))
addToChecklist("Real email address is needed", commit.sha);
}
if (Object.keys(checklist).length != 0) {
let msg = tag + "Problems found:\n";
for (const c in checklist)
msg += "- " + c + "<sup>" + checklist[c] + "</sup>\n";
console.log(msg);
}