-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat.js
46 lines (33 loc) · 1.05 KB
/
format.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
const template = `
The following commits do not follow the [Shopistan Commits][cc] rules:
<PLACEHOLDER>
<details>
<DETAILS>
</details>
You may need to [change the commit messages][ref] to comply with the \
repository contributing guidelines.
--------
🤖 This comment was generated by [**com-lint[bot]**][repo].
Happy coding!
[cc]: https://shopdev.atlassian.net/wiki/spaces/GEN/pages/16482354/Commit+lint+standards
[ref]: https://help.github.com/articles/changing-a-commit-message/
[repo]: https://github.com/Ammar-Knowledge/com-lint
`;
/**
* Formats array of commits warnings/errors as GitHub comment
*
* @param {Array} report
*/
function format(commits) {
let details = '';
let message = commits.map(c => `* ${c.sha}`).join('\n');
commits.forEach(c => {
details += `* Commit: ${c.sha}\n`;
details += c.errors.map(e => ` - ✖ ${e.message}\n`).join('');
details += c.warnings.map(w => ` - ⚠ ${w.message}\n`).join('');
});
return template
.replace('<PLACEHOLDER>', message)
.replace('<DETAILS>', details);
}
module.exports = format;