Skip to content

Commit 5a6289b

Browse files
committed
Merge remote-tracking branch 'origin/topic/bbannier/issue-956'
2 parents 406e366 + 295cd5b commit 5a6289b

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.2.0-dev.110 | 2021-07-29 15:01:46 +0200
2+
3+
* GH-956: Fix issues around generating version information. (Benjamin Bannier, Corelight)
4+
15
1.2.0-dev.105 | 2021-07-29 09:49:24 +0200
26

37
* GH-961: Make detection of current executable more robust. (Benjamin Bannier, Corelight)

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ execute_process(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/script
168168
OUTPUT_STRIP_TRAILING_WHITESPACE)
169169
set(CMAKE_PROJECT_VERSION ${SPICY_VERSION})
170170

171+
# Compute long version string for summary.
172+
execute_process(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/autogen-version --git-root ${CMAKE_CURRENT_SOURCE_DIR}
173+
OUTPUT_VARIABLE SPICY_VERSION_LONG
174+
OUTPUT_STRIP_TRAILING_WHITESPACE)
175+
171176
# Add subdirectories.
172177
add_subdirectory(hilti)
173178
add_subdirectory(spicy)
@@ -232,7 +237,7 @@ include(CPack)
232237
message(
233238
"\n====================| Spicy Build Summary |===================="
234239
"\n"
235-
"\nVersion: ${CMAKE_PROJECT_VERSION}"
240+
"\nVersion: ${SPICY_VERSION_LONG}"
236241
"\n"
237242
"\nBuild type: ${CMAKE_BUILD_TYPE}"
238243
"\nBuild directory: ${PROJECT_BINARY_DIR}"

scripts/autogen-version

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ import subprocess
1212
import tempfile
1313

1414

15-
def get_version(ref):
15+
def get_version(ref, prefer_recomputation=False):
16+
branch, hash, git_version = None, None, None
17+
1618
if os.path.exists("VERSION"):
1719
with open("VERSION", "r") as info:
18-
hash = info.readline().split("=")[1].strip()
1920
branch = info.readline().split("=")[1].strip()
21+
hash = info.readline().split("=")[1].strip()
2022
git_version = info.readline().split("=")[1].strip()
21-
return hash, branch, git_version
23+
24+
if not prefer_recomputation:
25+
return hash, branch, git_version
2226

2327
if subprocess.call(
2428
["git", "rev-parse", "--git-dir"],
@@ -51,10 +55,12 @@ def get_version(ref):
5155
git_version = re.sub(
5256
r"-([0-9]*)-g[0-9a-z]*", r".\1", re.sub(r"^v", "", raw_git_version)
5357
).strip()
54-
return hash, branch, git_version
5558

56-
print("Cannot extract version information: neither VERSION file nor git repository present")
57-
exit(1)
59+
if not any([hash, branch, git_version]):
60+
print("Cannot extract version information: neither VERSION file nor git repository present")
61+
exit(1)
62+
63+
return hash, branch, git_version
5864

5965

6066
def write_if_changed(target, txt):
@@ -110,7 +116,8 @@ os.chdir(
110116
if options.git_root
111117
else os.path.join(os.path.dirname(__file__), "..")
112118
)
113-
chash, branch, git_version = get_version(options.commit)
119+
chash, branch, git_version = get_version(
120+
ref=options.commit, prefer_recomputation=options.store)
114121

115122
# When running from CI, for geting the branch name we prefer what
116123
# might be passed in through environment variables as we may not
@@ -137,7 +144,6 @@ elif re.match("release.*", branch) or not branch:
137144
prerelease = commit
138145
else:
139146
prerelease = "branch"
140-
chash = ""
141147

142148
on_release_tag = subprocess.call(
143149
["git", "describe", "--tags", "--match", "v*", "--exact-match"],

0 commit comments

Comments
 (0)