diff --git a/danger/regressions.ts b/danger/regressions.ts index b42739c..de3ca52 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -6,10 +6,30 @@ declare const peril: any // danger/danger#351 const gh = danger.github as any as Issues const issue = gh.issue const repo = gh.repository -const text = (issue.title + issue.body).toLowerCase() +var text = (issue.title + issue.body).toLowerCase() const api = danger.github.api -if (text.includes("regression")) { +const startMarker = "" +const endMarker = "" + +var start = text.indexOf(startMarker); +var end = text.indexOf(endMarker) + +var hasRegressionChecked = false; + +if (start !== -1 && end !== -1) { + end = end + endMarker.length + + var regressionQuestion = text.substring(start, end); + text = text.replace(regressionQuestion, ''); + + if (regressionQuestion.includes("- [x] yes")) { + hasRegressionChecked = true; + } +} + +if (hasRegressionChecked || text.includes("regression")) { + console.log("IT HAS A REGRESSION"); var url = peril.env.SLACK_WEBHOOK_URL || ""; var webhook = new IncomingWebhook(url); schedule( async () => { diff --git a/settings.json b/settings.json index 1af9ec9..34f8a2e 100644 --- a/settings.json +++ b/settings.json @@ -4,7 +4,6 @@ "modules": ["@slack/client"] }, "rules": { - // https://artsy.github.io/blog/2017/09/04/Introducing-Peril/#Events - "issues.opened": "fastlane/peril-settings@danger/regressions.ts" + "issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" } }