From 73889817f0dde31d9cd5bd38e4d623864b37a544 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Mon, 22 May 2017 20:18:16 +0100 Subject: [PATCH] [Dev] Dangerfile add support for editing the PR body to provide a list of assignees and some metadata for cloning --- dangerfile.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/dangerfile.ts b/dangerfile.ts index 7bc81fc012..545d767acb 100644 --- a/dangerfile.ts +++ b/dangerfile.ts @@ -123,3 +123,43 @@ ${components} `) } + +// We'd like to improve visibility of whether someone has tested on a device, +// or run through the code at all. So, to look at improving this, we're going to try appending +// a checklist, and provide useful info on how to run the code yourself inside the PR. + +const splitter = `
` +const userBody = pr.body.split(splitter)[0] +const localBranch = `${pr.user.login}-${pr.number}-checkout` +const bodyFooter = ` +### Tested on Device? + +- [ ] @${pr.user.login} +${pr.assignees.map(assignee => `- [ ] @${assignee.login}`).join("\n")} + +
+ How to get set up with this PR? +

 

+

To run on your computer:

+
 git fetch origin pull/${pr.number}/head:${localBranch}
+git checkout ${localBranch}
+yarn install
+cd example; pod install cd ..
+yarn ios
+yarn start
+

+

To run inside Eigen (prod or beta) or Emission (beta): Shake the phone to get the Admin menu.

+

If you see "Use Staging React Env" - click that and restart, then follow the next step.

+

Click on "Choose an RN build" - then pick the one that says: "X,Y,Z"

+

Note: this is a TODO for PRs, currently you can only do it on master commits.

+
+` +const newBody = userBody + "\n" + splitter + "\n" + bodyFooter + +// The individual state of a ticked/unticket item in a markdown list should not +// require Danger to submit a new body (and thus overwrite those changes.) +const neuterMarkdownTicks = /- \[*.\]/g + +if (pr.body.replace(neuterMarkdownTicks, "-") !== newBody.replace(neuterMarkdownTicks, "-")) { + danger.github.api.pullRequests.update({...danger.github.thisPR, body: newBody }) +}