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.

Prev. Comments & Formatting #12

Merged
z0al merged 7 commits into z0al:master from newnewb:master
Jul 8, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/comments.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Checks for a previous bot comment, if found returns the commen
*/
async function checkComments(issues,pull){
const comments = await issues.getComments(pull)
return comment = comments.data.find(comment => comment.user.login === process.env.APP_NAME + '[bot]')
}

module.exports = checkComments
4 changes: 2 additions & 2 deletions lib/format.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function format(commits) {

commits.forEach(c => {
message += `* Commit: ${c.sha}\n`
message += c.errors.map(e => ` - ✖ ${e.message}\n`)
message += c.warnings.map(w => ` - ⚠ ${w.message}\n`)
message += c.errors.map(e => ` - ✖ ${e.message}\n`).join('')
message += c.warnings.map(w => ` - ⚠ ${w.message}\n`).join('')
})

return template.replace('<PLACEHOLDER>', message)
Expand Down
8 changes: 7 additions & 1 deletion lib/lint.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { lint, load } = require('@commitlint/core')
// Ours
const config = require('./config')
const format = require('./format')
const checkComments = require('./comments')

/**
* Runs commitlint against all commits of the pull request and sets an appropriate
Expand Down Expand Up @@ -64,7 +65,12 @@ async function commitlint(context) {
// Write a comment with the details (if any)
if (errorsCount > 0 || warnsCount > 0) {
const message = format(report.commits)
await issues.createComment({ ...pull, body: message })
const comment = await checkComments(issues,pull)
if(comment){ // edits previous bot comment if found
await issues.editComment({...pull,id:comment.id,body:message})
}else{ // if no previous comment create a new one
await issues.createComment({ ...pull, body: message })
}
}
})
}
Expand Down
Loading

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