From c1fb079a51065e7967505eab5d1a377a4465107c Mon Sep 17 00:00:00 2001 From: Cadence Fish Date: Tue, 28 Jan 2020 19:23:53 +1300 Subject: [PATCH] Try to provide commit hash in version --- src/site/api/api.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/site/api/api.js b/src/site/api/api.js index cd8c235..36b519d 100644 --- a/src/site/api/api.js +++ b/src/site/api/api.js @@ -1,4 +1,5 @@ const constants = require("../../lib/constants") +const child_process = require("child_process") const {fetchUser} = require("../../lib/collectors") function reply(statusCode, content) { @@ -9,6 +10,16 @@ function reply(statusCode, content) { } } +let commit = "" +{ + const p = child_process.spawn("git", ["rev-parse", "--short", "HEAD"]) + p.on("error", console.error) + p.stdout.on("data", data => { + const string = data.toString() + commit = "-" + string.match(/[0-9a-f]+/)[0] + }) +} + module.exports = [ { route: `/api/user/(${constants.external.username_regex})`, methods: ["GET"], code: async ({fill}) => { @@ -35,7 +46,7 @@ module.exports = [ version: "2.0", software: { name: "bibliogram", - version: "1.0.0" + version: "1.0.0"+commit }, protocols: [], services: {