Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidy up config checks #43

Merged
merged 2 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ module.exports = app => {
}

if (eventSrc === 'pullRequest') {
if (!(await PullRequestBodyChecker.isBodyValid(body, config, context))) {
if (config.checkPullRequestTemplate && !(await PullRequestBodyChecker.isBodyValid(body, context))) {
badBody = true
}
} else if (eventSrc === 'issue') {
if (!(await IssueBodyChecker.isBodyValid(body, config, context))) {
if (config.checkIssueTemplate && !(await IssueBodyChecker.isBodyValid(body, context))) {
badBody = true
}
}
Expand Down
7 changes: 2 additions & 5 deletions lib/IssueBodyChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,12 @@ async function isBodyEqualToTemplate (body, context) {
}

class IssueBodyChecker {
static async isBodyValid (body, config, context) {
static async isBodyValid (body, context) {
if (!body) {
return false
}

if (
config.checkIssueTemplate &&
(await isBodyEqualToTemplate(body, context))
) {
if (await isBodyEqualToTemplate(body, context)) {
return false
}

Expand Down
4 changes: 2 additions & 2 deletions lib/PullRequestBodyChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ async function isBodyEqualToTemplate (body, context) {
}

class PullRequestBodyChecker {
static async isBodyValid (body, config, context) {
static async isBodyValid (body, context) {
if (!body) {
return false
}

if (config.checkPullRequestTemplate && await isBodyEqualToTemplate(body, context)) {
if (await isBodyEqualToTemplate(body, context)) {
return false
}

Expand Down