From 080139a2dfe1bd9b4be7e7fb19078d82a4e81a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 15 Jan 2019 21:07:25 +0100 Subject: [PATCH] move the list of builds to a separate partial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- src/comments.js | 3 ++- src/template.js | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/comments.js b/src/comments.js index 6dffe84..bd7e168 100644 --- a/src/comments.js +++ b/src/comments.js @@ -34,7 +34,8 @@ class Comments { /* add helper for checking change in commit */ Handlebars.registerHelper('commitChanged', commitHelper) /* setup templating for comments */ - this.template = Handlebars.compile(template); + Handlebars.registerPartial('build', template.build) + this.template = Handlebars.compile(template.main); } async renderComment (pr) { diff --git a/src/template.js b/src/template.js index 26f826d..ba3895e 100644 --- a/src/template.js +++ b/src/template.js @@ -1,4 +1,4 @@ -module.exports = ` +const main = ` ### Jenkins Builds | :grey_question: | Commit | :hash: | Finished (UTC) | Duration | Platform | Result | |-|-|-|-|-|-|-| @@ -6,10 +6,14 @@ module.exports = ` {{#commitChanged ../builds @index}} | | | | | | | | {{/commitChanged}} +{{> build }} +{{/each}} +` +const build = ` {{#if this.success}} | :heavy_check_mark: | {{ this.commit }} | [{{ this.id }}]({{ this.url }}) | {{date this.meta.created }} | {{ this.duration }} | \`{{ this.platform }}\` | [:package: package]({{ this.pkg_url }}) | {{else}} | :x: | {{ this.commit }} | [{{ this.id }}]({{ this.url }}) | {{date this.meta.created }} | {{ this.duration }} | \`{{ this.platform }}\` | [:page_facing_up: build log]({{ this.url }}consoleText) | {{/if}} -{{/each}} -` +`.trim() +module.exports = { main, build }