From 2e76f693945852bb9d51b2657b07bbdcb117d0f5 Mon Sep 17 00:00:00 2001 From: David Terry Date: Mon, 10 Feb 2020 16:32:23 +0100 Subject: [PATCH] overview: show git branch --- lib/util.js | 13 +++++++++++++ libexec/klab-report | 6 ++++-- resources/overview.js | 2 +- resources/overview.scss | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/util.js b/lib/util.js index 08695dff..fa4c8052 100644 --- a/lib/util.js +++ b/lib/util.js @@ -82,6 +82,18 @@ const getKlabHEAD = () => { }); } +const getProjectBranch = () => { + let branch = ""; + + if(testPath('.git')) { + branch = execSync(`git rev-parse --abbrev-ref HEAD`, { + encoding: 'utf8' + }).trim(); + } + + return branch +} + const getProjectHEAD = () => { var project_HEAD = ""; @@ -124,5 +136,6 @@ module.exports = { getBuildId, getKlabHEAD, getProjectHEAD, + getProjectBranch, getStatus }; diff --git a/libexec/klab-report b/libexec/klab-report index 24b903a9..a6b20d8e 100755 --- a/libexec/klab-report +++ b/libexec/klab-report @@ -15,7 +15,8 @@ const { sha3, getBuildId, getKlabHEAD, - getProjectHEAD + getProjectHEAD, + getProjectBranch } = require("../lib/util.js") const fs = require("fs"); const KLAB_OUT = process.env.KLAB_OUT || "out"; @@ -444,7 +445,8 @@ const json_report = { [build_hash]: { date: new Date(), proofs, - git: project_HEAD + git: project_HEAD, + branch: getProjectBranch() }, url: config.url, name: config.name diff --git a/resources/overview.js b/resources/overview.js index c393bb41..d70a83e8 100644 --- a/resources/overview.js +++ b/resources/overview.js @@ -142,7 +142,7 @@ loadJSON(json => { h(["div", 'class="proofinfo"'])([ h(["div", 'class="link"'])([ h(['a', 'class="build-hash"', `href="${o.hash}"`])(o.hash), - h(['span', 'class="proj-hash"'])(`proj: ${o.git}`), + h(['span', 'class="git-rev"'])(`rev: ${o.git.substring(0,8)}${o.branch ? ` (${o.branch})` : ''}`), h(['div', 'class="info"'])([ date(o.date), h(['span', 'class="running"'])(running ? 'running (' + skip.length + ')' : '') diff --git a/resources/overview.scss b/resources/overview.scss index 6f6d835e..9d5cdf04 100644 --- a/resources/overview.scss +++ b/resources/overview.scss @@ -62,7 +62,7 @@ a { } } - .proj-hash { + .git-rev { display: block; font-size: 0.7em; }