-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changelog-setup.js
59 lines (51 loc) · 1.57 KB
/
changelog-setup.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
57
58
59
module.exports = function (Handlebars) {
Handlebars.registerHelper('full-commit-list', (commits, merges, fixes, options) => {
commits = commits
.concat(merges.map((merge) => merge.commit))
.concat(fixes.map((fix) => fix.commit));
if (!commits || commits.length === 0) {
return '';
}
const { exclude, message, subject, heading } = options.hash;
const list = commits
.filter((item) => {
const commit = item.commit || item;
// Exclude commits where subject includes with "Release v"
if (commit.subject.includes('Release v')) {
return false;
}
if (exclude) {
const excludeList = exclude.split('|');
for (const e of excludeList) {
const pattern = new RegExp(e, 'm');
if (pattern.test(commit.message)) {
return false;
}
}
}
if (message) {
const pattern = new RegExp(message, 'm');
return pattern.test(commit.message);
}
if (subject) {
const pattern = new RegExp(subject);
const match = pattern.test(commit.subject);
if (match) {
// remove the message from the commit subject and message and trim
commit.subject = commit.subject.replace(pattern, '').trim();
}
return match;
}
return true;
})
.map((item) => options.fn(item))
.join('');
if (!list) {
return '';
}
if (!heading) {
return list;
}
return `${heading}\n\n${list}`;
});
};