1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const ActionResult_1 = require("../../action/ActionResult");
|
4 | const gitHub_1 = require("../../util/gitHub");
|
5 | const GitHubRepoRef_1 = require("../common/GitHubRepoRef");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | exports.issueRaisingReviewRouter = (pr, params, name) => {
|
14 | if (GitHubRepoRef_1.isGitHubRepoRef(pr.repoId)) {
|
15 | const issue = toIssue(pr, name);
|
16 | return gitHub_1.raiseIssue(params.targets.credentials.token, pr.repoId, issue)
|
17 | .then(ap => ActionResult_1.successOn(pr.repoId));
|
18 | }
|
19 | else {
|
20 | return Promise.resolve(ActionResult_1.failureOn(pr.repoId, new Error(`Not a GitHub Repo: ${JSON.stringify(pr.repoId)}`)));
|
21 | }
|
22 | };
|
23 | function toIssue(pr, name) {
|
24 | return {
|
25 | title: `${pr.comments.length} problems found by ${name}`,
|
26 | body: "Problems:\n\n" + pr.comments.map(c => toMarkdown(pr.repoId, c)).join("\n"),
|
27 | };
|
28 | }
|
29 | function toMarkdown(grr, rc) {
|
30 | return `-\t**${rc.severity}** - ${rc.category}: [${rc.detail}](${gitHub_1.deepLink(grr, rc.sourceLocation)})`;
|
31 | }
|
32 |
|
\ | No newline at end of file |