From abb2c7927ca1640a755e0ec32c51bcc9c873b34c Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sat, 29 Sep 2018 19:53:49 +0200 Subject: show last commit hash alongside server version in footer --- server/helpers/utils.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'server/helpers') diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index a42474417..f5bf6de56 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -54,6 +54,18 @@ function getSecureTorrentName (originalName: string) { return sha256(originalName) + '.torrent' } +function getVersion () { + const tag = require('child_process') + .execSync('[[ ! -d .git ]] || git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || true', { stdio: [0,1,2] }) + if (tag) return tag.replace(/^v/, '') + + const version = require('child_process') + .execSync('[[ ! -d .git ]] || git rev-parse --short HEAD').toString().trim() + if (version) return version + + return require('../../../package.json').version +} + // --------------------------------------------------------------------------- export { @@ -62,5 +74,6 @@ export { getFormattedObjects, getSecureTorrentName, getServerActor, + getVersion, generateVideoTmpPath } -- cgit v1.2.3