From 269d6ade16dfa64fe3b6025c360f8f672268aa44 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 20:58:20 -0500 Subject: [PATCH 01/31] Update settings.json --- settings.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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" } } From 10f7e5de8552cef28f295d94f732da0a999834d5 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:21:48 -0500 Subject: [PATCH 02/31] Update settings.json --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 34f8a2e..b4d578a 100644 --- a/settings.json +++ b/settings.json @@ -4,6 +4,6 @@ "modules": ["@slack/client"] }, "rules": { - "issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" + //"issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" } } From c78544d8093b01f687b4cfe21f3ece2e4ee63e8a Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:22:09 -0500 Subject: [PATCH 03/31] Update settings.json --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index b4d578a..39434f3 100644 --- a/settings.json +++ b/settings.json @@ -4,6 +4,6 @@ "modules": ["@slack/client"] }, "rules": { - //"issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" + ///"issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" } } From 72f27ad7dd7078c56e1dca5311d4cca3219d6500 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:22:25 -0500 Subject: [PATCH 04/31] Update settings.json --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 39434f3..b4d578a 100644 --- a/settings.json +++ b/settings.json @@ -4,6 +4,6 @@ "modules": ["@slack/client"] }, "rules": { - ///"issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" + //"issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" } } From 315e2cd2f6986b3a54dd89d6cf12844a64a31aba Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:24:31 -0500 Subject: [PATCH 05/31] Update settings.json --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index b4d578a..34f8a2e 100644 --- a/settings.json +++ b/settings.json @@ -4,6 +4,6 @@ "modules": ["@slack/client"] }, "rules": { - //"issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" + "issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" } } From dcd2bc41291e0e0a0d8e318a338567358876fa26 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:27:30 -0500 Subject: [PATCH 06/31] Create test.ts --- danger/test.ts | 1 + 1 file changed, 1 insertion(+) create mode 100644 danger/test.ts diff --git a/danger/test.ts b/danger/test.ts new file mode 100644 index 0000000..b65c81a --- /dev/null +++ b/danger/test.ts @@ -0,0 +1 @@ +console.log("test here") From 7db1a4a6195fba14dfcbb20c66d5d26b29e5f2e3 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:27:41 -0500 Subject: [PATCH 07/31] Update settings.json --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 34f8a2e..9a5b507 100644 --- a/settings.json +++ b/settings.json @@ -4,6 +4,6 @@ "modules": ["@slack/client"] }, "rules": { - "issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" + "issues.opened": "joshdholtz/peril-settings@danger/test.ts" } } From 6d7ce71b9fb4ed267481a0f33f4a614b997b7744 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:32:28 -0500 Subject: [PATCH 08/31] Update settings.json --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 9a5b507..34f8a2e 100644 --- a/settings.json +++ b/settings.json @@ -4,6 +4,6 @@ "modules": ["@slack/client"] }, "rules": { - "issues.opened": "joshdholtz/peril-settings@danger/test.ts" + "issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" } } From 608b8f4d1e061cab4c31ae9c3c732aae20f32649 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:33:40 -0500 Subject: [PATCH 09/31] Update regressions.ts --- danger/regressions.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index b42739c..f7e8eda 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -10,6 +10,7 @@ const text = (issue.title + issue.body).toLowerCase() const api = danger.github.api if (text.includes("regression")) { + console.log("IT HAS A REGRESSION"); var url = peril.env.SLACK_WEBHOOK_URL || ""; var webhook = new IncomingWebhook(url); schedule( async () => { @@ -21,8 +22,9 @@ if (text.includes("regression")) { title: issue.title, title_link: issue.html_url, author_name: issue.user.login, - author_icon: issue.user.avatar_url, - channel: "C0RNLRLG6" + author_icon: issue.user.avatar_url +// , +// channel: "C0RNLRLG6" }] }) From cb6c4a166b463ffe24f9e39cc36ff3c499ba99e1 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:36:58 -0500 Subject: [PATCH 10/31] Update test.ts --- danger/test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/danger/test.ts b/danger/test.ts index b65c81a..b0a1ab5 100644 --- a/danger/test.ts +++ b/danger/test.ts @@ -1 +1,7 @@ -console.log("test here") +console.log("start here") + +import { schedule, danger } from "danger"; +import { IncomingWebhook } from "@slack/client"; +import { Issues } from "github-webhook-event-types" + +console.log("end test"); From 8b0b0c390267d65e54e118b15613da3a88339d3b Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:37:15 -0500 Subject: [PATCH 11/31] Update settings.json --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 34f8a2e..9a5b507 100644 --- a/settings.json +++ b/settings.json @@ -4,6 +4,6 @@ "modules": ["@slack/client"] }, "rules": { - "issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" + "issues.opened": "joshdholtz/peril-settings@danger/test.ts" } } From cc1f41ba936ec400db75c080675a9bed5b97cb12 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:38:47 -0500 Subject: [PATCH 12/31] Update test.ts --- danger/test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/danger/test.ts b/danger/test.ts index b0a1ab5..9e992d0 100644 --- a/danger/test.ts +++ b/danger/test.ts @@ -4,4 +4,11 @@ import { schedule, danger } from "danger"; import { IncomingWebhook } from "@slack/client"; import { Issues } from "github-webhook-event-types" +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() +const api = danger.github.api + console.log("end test"); From 0dbc1ffc6a49585a21e12228d41e505401a575f2 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:40:10 -0500 Subject: [PATCH 13/31] Update test.ts --- danger/test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/danger/test.ts b/danger/test.ts index 9e992d0..5d5bf37 100644 --- a/danger/test.ts +++ b/danger/test.ts @@ -11,4 +11,6 @@ const repo = gh.repository const text = (issue.title + issue.body).toLowerCase() const api = danger.github.api +console.log("text", text); + console.log("end test"); From b2ee9e5d3f2bbffbf950888cf61450e4b279b59a Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:42:19 -0500 Subject: [PATCH 14/31] Update test.ts --- danger/test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/danger/test.ts b/danger/test.ts index 5d5bf37..e4577ff 100644 --- a/danger/test.ts +++ b/danger/test.ts @@ -13,4 +13,34 @@ const api = danger.github.api console.log("text", text); +if (text.includes("regression")) { + console.log("IT HAS A REGRESSION"); + var url = peril.env.SLACK_WEBHOOK_URL || ""; + var webhook = new IncomingWebhook(url); + + console.log("url", url); + +// schedule( async () => { +// await webhook.send({ +// unfurl_links: false, +// attachments: [{ +// pretext: "New PR/Issue containing the word 'regression'", +// color: "danger", +// title: issue.title, +// title_link: issue.html_url, +// author_name: issue.user.login, +// author_icon: issue.user.avatar_url, +// channel: "C0RNLRLG6" +// }] +// }) + +// await api.issues.addLabels({ +// owner: repo.owner.login, +// repo: repo.name, +// number: issue.number, +// labels: ["status: regression"] +// }) +// }); +} + console.log("end test"); From 07318ca7976f6bfe98bcfff156780cb65dfabfb4 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:43:19 -0500 Subject: [PATCH 15/31] Update test.ts --- danger/test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/danger/test.ts b/danger/test.ts index e4577ff..aad27db 100644 --- a/danger/test.ts +++ b/danger/test.ts @@ -13,12 +13,12 @@ const api = danger.github.api console.log("text", text); -if (text.includes("regression")) { - console.log("IT HAS A REGRESSION"); - var url = peril.env.SLACK_WEBHOOK_URL || ""; - var webhook = new IncomingWebhook(url); +// if (text.includes("regression")) { +// console.log("IT HAS A REGRESSION"); +// var url = peril.env.SLACK_WEBHOOK_URL || ""; +// var webhook = new IncomingWebhook(url); - console.log("url", url); +// console.log("url", url); // schedule( async () => { // await webhook.send({ @@ -41,6 +41,6 @@ if (text.includes("regression")) { // labels: ["status: regression"] // }) // }); -} +// } console.log("end test"); From b545b88c457d8e8bb99a80edc89bd36e58a6c55b Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:44:41 -0500 Subject: [PATCH 16/31] Update test.ts --- danger/test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/danger/test.ts b/danger/test.ts index aad27db..822b293 100644 --- a/danger/test.ts +++ b/danger/test.ts @@ -13,8 +13,8 @@ const api = danger.github.api console.log("text", text); -// if (text.includes("regression")) { -// console.log("IT HAS A REGRESSION"); +if (text.includes("regression")) { + console.log("IT HAS A REGRESSION"); // var url = peril.env.SLACK_WEBHOOK_URL || ""; // var webhook = new IncomingWebhook(url); @@ -41,6 +41,6 @@ console.log("text", text); // labels: ["status: regression"] // }) // }); -// } +} console.log("end test"); From 96aa95c24f74231527a0a22282acae8d2a2200e4 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:45:48 -0500 Subject: [PATCH 17/31] Update test.ts --- danger/test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/danger/test.ts b/danger/test.ts index 822b293..e8855b9 100644 --- a/danger/test.ts +++ b/danger/test.ts @@ -15,10 +15,10 @@ console.log("text", text); if (text.includes("regression")) { console.log("IT HAS A REGRESSION"); -// var url = peril.env.SLACK_WEBHOOK_URL || ""; + var url = peril.env.SLACK_WEBHOOK_URL || ""; // var webhook = new IncomingWebhook(url); -// console.log("url", url); + console.log("url", url); // schedule( async () => { // await webhook.send({ From b6438e2cc59e6dd226592e982d4484c50bcc6160 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:48:21 -0500 Subject: [PATCH 18/31] Update test.ts --- danger/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/danger/test.ts b/danger/test.ts index e8855b9..e4577ff 100644 --- a/danger/test.ts +++ b/danger/test.ts @@ -16,7 +16,7 @@ console.log("text", text); if (text.includes("regression")) { console.log("IT HAS A REGRESSION"); var url = peril.env.SLACK_WEBHOOK_URL || ""; -// var webhook = new IncomingWebhook(url); + var webhook = new IncomingWebhook(url); console.log("url", url); From 1c9acb70e63202c57c0b973ead5ce1ebbb172dff Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 21:56:34 -0500 Subject: [PATCH 19/31] Update test.ts --- danger/test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/danger/test.ts b/danger/test.ts index e4577ff..e136ceb 100644 --- a/danger/test.ts +++ b/danger/test.ts @@ -16,7 +16,8 @@ console.log("text", text); if (text.includes("regression")) { console.log("IT HAS A REGRESSION"); var url = peril.env.SLACK_WEBHOOK_URL || ""; - var webhook = new IncomingWebhook(url); + console.log('IncomingWebhook', IncomingWebhook); +// var webhook = new IncomingWebhook(url); console.log("url", url); From 9819e8e4a025270d3545659ec894d5072105bc57 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:00:49 -0500 Subject: [PATCH 20/31] Update settings.json --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 9a5b507..34f8a2e 100644 --- a/settings.json +++ b/settings.json @@ -4,6 +4,6 @@ "modules": ["@slack/client"] }, "rules": { - "issues.opened": "joshdholtz/peril-settings@danger/test.ts" + "issues.opened": "joshdholtz/peril-settings@danger/regressions.ts" } } From 0a5aa706dedba8d0172d4e4cff7933441c796251 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:15:11 -0500 Subject: [PATCH 21/31] Update regressions.ts --- danger/regressions.ts | 55 +++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index f7e8eda..a62b1aa 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -9,30 +9,33 @@ const repo = gh.repository const text = (issue.title + issue.body).toLowerCase() const api = danger.github.api -if (text.includes("regression")) { - console.log("IT HAS A REGRESSION"); - var url = peril.env.SLACK_WEBHOOK_URL || ""; - var webhook = new IncomingWebhook(url); - schedule( async () => { - await webhook.send({ - unfurl_links: false, - attachments: [{ - pretext: "New PR/Issue containing the word 'regression'", - color: "danger", - title: issue.title, - title_link: issue.html_url, - author_name: issue.user.login, - author_icon: issue.user.avatar_url -// , -// channel: "C0RNLRLG6" - }] - }) +var strippedAlphabet = alphabet.replace(/H.*S/, 'HS'); +console.log("strippedAlphabet", strippedAlphabet) - await api.issues.addLabels({ - owner: repo.owner.login, - repo: repo.name, - number: issue.number, - labels: ["status: regression"] - }) - }); -} +// if (text.includes("regression")) { +// console.log("IT HAS A REGRESSION"); +// var url = peril.env.SLACK_WEBHOOK_URL || ""; +// var webhook = new IncomingWebhook(url); +// schedule( async () => { +// await webhook.send({ +// unfurl_links: false, +// attachments: [{ +// pretext: "New PR/Issue containing the word 'regression'", +// color: "danger", +// title: issue.title, +// title_link: issue.html_url, +// author_name: issue.user.login, +// author_icon: issue.user.avatar_url +// // , +// // channel: "C0RNLRLG6" +// }] +// }) + +// await api.issues.addLabels({ +// owner: repo.owner.login, +// repo: repo.name, +// number: issue.number, +// labels: ["status: regression"] +// }) +// }); +// } From ce53ba3dcb89fdaaef865177a38224ace2330460 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:15:31 -0500 Subject: [PATCH 22/31] Update regressions.ts --- danger/regressions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index a62b1aa..ffd2ed2 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -9,7 +9,7 @@ const repo = gh.repository const text = (issue.title + issue.body).toLowerCase() const api = danger.github.api -var strippedAlphabet = alphabet.replace(/H.*S/, 'HS'); +var strippedAlphabet = text.replace(/H.*S/, 'HS'); console.log("strippedAlphabet", strippedAlphabet) // if (text.includes("regression")) { From 3e1fbb9768d4a3e37762b154b195f5d8e3a24c8e Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:17:35 -0500 Subject: [PATCH 23/31] Update regressions.ts --- danger/regressions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index ffd2ed2..ec56539 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -9,7 +9,7 @@ const repo = gh.repository const text = (issue.title + issue.body).toLowerCase() const api = danger.github.api -var strippedAlphabet = text.replace(/H.*S/, 'HS'); +var strippedAlphabet = text.replace(/h.*s/, 'hs'); console.log("strippedAlphabet", strippedAlphabet) // if (text.includes("regression")) { From 10a8be1a7ae25717be121bfe975274818f39d885 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:28:00 -0500 Subject: [PATCH 24/31] Update regressions.ts --- danger/regressions.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index ec56539..aa95286 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -6,11 +6,21 @@ 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 -var strippedAlphabet = text.replace(/h.*s/, 'hs'); -console.log("strippedAlphabet", strippedAlphabet) +var start = text.indexOf(""); +var end = text.indexOf("") + +if (start !== -1 && end !== -1) { + end = "".length + + var ignoreContent = text.substring(start, end); + console.log("text before: " + text); + text = text.replace(ignoreContent, ''); + console.log("text after: " + text); +} + // if (text.includes("regression")) { // console.log("IT HAS A REGRESSION"); From aacb062ad19c8d45205b0fe4d9cc24a21e5de5db Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:30:04 -0500 Subject: [PATCH 25/31] Update regressions.ts --- danger/regressions.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index aa95286..d10c8e4 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -9,11 +9,14 @@ const repo = gh.repository var text = (issue.title + issue.body).toLowerCase() const api = danger.github.api -var start = text.indexOf(""); -var end = text.indexOf("") +const startMarker = "" +const endMarker = "" + +var start = text.indexOf(startMarker); +var end = text.indexOf(endMarker) if (start !== -1 && end !== -1) { - end = "".length + end = end + endMarker.length var ignoreContent = text.substring(start, end); console.log("text before: " + text); From bdc9ec82a7a89601a83e90dd91c101dac43920e7 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:31:46 -0500 Subject: [PATCH 26/31] Update regressions.ts --- danger/regressions.ts | 51 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index d10c8e4..59ba833 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -25,30 +25,29 @@ if (start !== -1 && end !== -1) { } -// if (text.includes("regression")) { -// console.log("IT HAS A REGRESSION"); -// var url = peril.env.SLACK_WEBHOOK_URL || ""; -// var webhook = new IncomingWebhook(url); -// schedule( async () => { -// await webhook.send({ -// unfurl_links: false, -// attachments: [{ -// pretext: "New PR/Issue containing the word 'regression'", -// color: "danger", -// title: issue.title, -// title_link: issue.html_url, -// author_name: issue.user.login, -// author_icon: issue.user.avatar_url -// // , -// // channel: "C0RNLRLG6" -// }] -// }) +if (text.includes("regression")) { + console.log("IT HAS A REGRESSION"); + var url = peril.env.SLACK_WEBHOOK_URL || ""; + var webhook = new IncomingWebhook(url); + schedule( async () => { + await webhook.send({ + unfurl_links: false, + attachments: [{ + pretext: "New PR/Issue containing the word 'regression'", + color: "danger", + title: issue.title, + title_link: issue.html_url, + author_name: issue.user.login, + author_icon: issue.user.avatar_url, +// channel: "C0RNLRLG6" + }] + }) -// await api.issues.addLabels({ -// owner: repo.owner.login, -// repo: repo.name, -// number: issue.number, -// labels: ["status: regression"] -// }) -// }); -// } + await api.issues.addLabels({ + owner: repo.owner.login, + repo: repo.name, + number: issue.number, + labels: ["status: regression"] + }) + }); +} From 76e8ecd587b7bfb5051a512c1af5a366d736ac16 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:40:35 -0500 Subject: [PATCH 27/31] Update regressions.ts --- danger/regressions.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index 59ba833..28b85ca 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -9,23 +9,32 @@ const repo = gh.repository var text = (issue.title + issue.body).toLowerCase() const api = danger.github.api -const startMarker = "" -const endMarker = "" +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 ignoreContent = text.substring(start, end); + var regressionQuestion = text.substring(start, end); + + if (regressionQuestion.includes("- [x] Yes")) { + hasRegressionChecked = true; + } + console.log("text before: " + text); text = text.replace(ignoreContent, ''); console.log("text after: " + text); } +console.log("hasRegressionChecked", hasRegressionChecked); +console.log("text includes", text.includes("regression")); -if (text.includes("regression")) { +if (hasRegressionChecked || text.includes("regression")) { console.log("IT HAS A REGRESSION"); var url = peril.env.SLACK_WEBHOOK_URL || ""; var webhook = new IncomingWebhook(url); From 7e4ccf129ff2fde1fe2ff65ec29fde2bcee43a0d Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:42:10 -0500 Subject: [PATCH 28/31] Update regressions.ts --- danger/regressions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index 28b85ca..fd37e6b 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -27,7 +27,7 @@ if (start !== -1 && end !== -1) { } console.log("text before: " + text); - text = text.replace(ignoreContent, ''); + text = text.replace(regressionQuestion, ''); console.log("text after: " + text); } From 45ad5c462dce28e04ad1cedb900aac463743b776 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:43:02 -0500 Subject: [PATCH 29/31] Update regressions.ts --- danger/regressions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index fd37e6b..b47289c 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -22,7 +22,7 @@ if (start !== -1 && end !== -1) { var regressionQuestion = text.substring(start, end); - if (regressionQuestion.includes("- [x] Yes")) { + if (regressionQuestion.includes("- [x] yes")) { hasRegressionChecked = true; } From 897dba649f3e7816f1d2c7f712e31befe4cbc13f Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:45:31 -0500 Subject: [PATCH 30/31] Update regressions.ts --- danger/regressions.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/danger/regressions.ts b/danger/regressions.ts index b47289c..de3ca52 100644 --- a/danger/regressions.ts +++ b/danger/regressions.ts @@ -20,20 +20,14 @@ var hasRegressionChecked = false; if (start !== -1 && end !== -1) { end = end + endMarker.length - var regressionQuestion = text.substring(start, end); + var regressionQuestion = text.substring(start, end); + text = text.replace(regressionQuestion, ''); if (regressionQuestion.includes("- [x] yes")) { hasRegressionChecked = true; } - - console.log("text before: " + text); - text = text.replace(regressionQuestion, ''); - console.log("text after: " + text); } -console.log("hasRegressionChecked", hasRegressionChecked); -console.log("text includes", text.includes("regression")); - if (hasRegressionChecked || text.includes("regression")) { console.log("IT HAS A REGRESSION"); var url = peril.env.SLACK_WEBHOOK_URL || ""; @@ -48,7 +42,7 @@ if (hasRegressionChecked || text.includes("regression")) { title_link: issue.html_url, author_name: issue.user.login, author_icon: issue.user.avatar_url, -// channel: "C0RNLRLG6" + channel: "C0RNLRLG6" }] }) From d5ff2274810e9718c9e982af7017101105715f84 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 16 Apr 2018 22:45:47 -0500 Subject: [PATCH 31/31] Delete test.ts --- danger/test.ts | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 danger/test.ts diff --git a/danger/test.ts b/danger/test.ts deleted file mode 100644 index e136ceb..0000000 --- a/danger/test.ts +++ /dev/null @@ -1,47 +0,0 @@ -console.log("start here") - -import { schedule, danger } from "danger"; -import { IncomingWebhook } from "@slack/client"; -import { Issues } from "github-webhook-event-types" - -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() -const api = danger.github.api - -console.log("text", text); - -if (text.includes("regression")) { - console.log("IT HAS A REGRESSION"); - var url = peril.env.SLACK_WEBHOOK_URL || ""; - console.log('IncomingWebhook', IncomingWebhook); -// var webhook = new IncomingWebhook(url); - - console.log("url", url); - -// schedule( async () => { -// await webhook.send({ -// unfurl_links: false, -// attachments: [{ -// pretext: "New PR/Issue containing the word 'regression'", -// color: "danger", -// title: issue.title, -// title_link: issue.html_url, -// author_name: issue.user.login, -// author_icon: issue.user.avatar_url, -// channel: "C0RNLRLG6" -// }] -// }) - -// await api.issues.addLabels({ -// owner: repo.owner.login, -// repo: repo.name, -// number: issue.number, -// labels: ["status: regression"] -// }) -// }); -} - -console.log("end test");