From 499b870a1a8e6688ff03b958709955075064b7e5 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 30 Mar 2023 19:59:36 +0300 Subject: [PATCH] Allow the git revision to be specified with -d:git_revision_override=xxxxxx --- beacon_chain/version.nim | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/beacon_chain/version.nim b/beacon_chain/version.nim index bc554754f..131f9b429 100644 --- a/beacon_chain/version.nim +++ b/beacon_chain/version.nim @@ -9,7 +9,7 @@ {.push raises: [].} -import strutils +import std/[strutils, compilesettings] when not defined(nimscript): import times @@ -22,7 +22,25 @@ const versionBlob* = "stateofus" # Single word - ends up in the default graffiti - gitRevision* = strip(staticExec("git rev-parse --short HEAD"))[0..5] + ## You can override this if you are building the + ## sources outside the git tree of Nimbus: + git_revision_override* {.strdefine.} = + when querySetting(SingleValueSetting.command) == "check": + # The staticExec call below returns an empty string + # when `nim check` is used and this leads to a faux + # compile-time error. + # We work-around the problem with this override and + # save some time in executing the external command. + "123456" + else: + "" + + gitRevisionLong* = when git_revision_override.len == 0: + staticExec "git rev-parse --short HEAD" + else: + git_revision_override + + gitRevision* = strip(gitRevisionLong)[0..5] nimFullBanner* = staticExec("nim --version") nimBanner* = staticExec("nim --version | grep Version")