Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 1, 2020. It is now read-only.

Commit 1ed052a

Browse files
committed
refactor(lint): only call format when necessary
1 parent 949b84f commit 1ed052a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

‎lib/lint.js‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ async function commitlint(context) {
3131
// Paginate all PR commits
3232
return paginate(pullRequests.getCommits(pull), async ({ data }) => {
3333
// empty summary
34-
const report = { valid: true, commits: {} }
34+
const report = { valid: true, commits: [] }
3535
const { rules } = await load(config)
3636

37+
// Keep counters
38+
let errorsCount = 0
39+
let warnsCount = 0
40+
3741
// Iterates over all commits
3842
for (const d of data) {
3943
const { valid, errors, warnings } = await lint(d.commit.message, rules)
@@ -42,21 +46,24 @@ async function commitlint(context) {
4246
}
4347

4448
if (errors.length > 0 || warnings.length > 0) {
45-
report.commits[d.sha] = { errors, warnings }
49+
// Update counts
50+
errorsCount += errors.length
51+
warnsCount += warnings.length
52+
53+
report.commits.push({ sha: d.sha, errors, warnings })
4654
}
4755
}
4856

49-
const { summary, message } = format(report)
50-
5157
// Final status
5258
await repos.createStatus({
5359
...statusInfo,
5460
state: report.valid ? 'success' : 'failure',
55-
description: summary
61+
description: `found ${errorsCount} problems, ${warnsCount} warnings`
5662
})
5763

5864
// Write a comment with the details (if any)
59-
if (message) {
65+
if (errorsCount > 0 || warnsCount > 0) {
66+
const message = format(report.commits)
6067
await issues.createComment({ ...pull, body: message })
6168
}
6269
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /