authorgravatar for jay@jayschwa.netJay Petacat <jay@jayschwa.net> 2020-12-30 20:57:50-06:00
committergravatar for jay@jayschwa.netJay Petacat <jay@jayschwa.net> 2020-12-30 20:57:50-06:00
log02438aabe3a04ac8ca2a2e0b2501ba18885652e3
treebc2deec16503a82dfc836e65291728f944bd5ba5
parent4af763d401b48f7186650335c8e42e8fe29751bf

Remove 'g' prefix from commit hash in Zig semver


2 files changed, 9 insertions(+), 3 deletions(-)

CMakeLists.txt+1-1
...@@ -46,7 +46,7 @@ if("${ZIG_VERSION}" STREQUAL "")...@@ -46,7 +46,7 @@ if("${ZIG_VERSION}" STREQUAL "")
46 if(NOT GIT_TAG VERSION_EQUAL ZIG_VERSION)46 if(NOT GIT_TAG VERSION_EQUAL ZIG_VERSION)
47 message(SEND_ERROR "Zig version (${ZIG_VERSION}) does not match Git tag (${GIT_TAG}).")47 message(SEND_ERROR "Zig version (${ZIG_VERSION}) does not match Git tag (${GIT_TAG}).")
48 endif()48 endif()
49 elseif(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-(.+)$")49 elseif(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-g(.+)$")
50 # Untagged pre-release. The Zig version is updated to include the number of commits50 # Untagged pre-release. The Zig version is updated to include the number of commits
51 # since the last tagged version and the commit hash. The version is formatted in51 # since the last tagged version and the commit hash. The version is formatted in
52 # accordance with the https://semver.org specification.52 # accordance with the https://semver.org specification.
build.zig+8-2
...@@ -256,11 +256,17 @@ pub fn build(b: *Builder) !void {...@@ -256,11 +256,17 @@ pub fn build(b: *Builder) !void {
256 std.process.exit(1);256 std.process.exit(1);
257 }257 }
258258
259 // Check that the commit hash is prefixed with a 'g' (a Git convention).
260 if (commit_id.len < 1 or commit_id[0] != 'g') {
261 std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe});
262 break :v version_string;
263 }
264
259 // The version is reformatted in accordance with the https://semver.org specification.265 // The version is reformatted in accordance with the https://semver.org specification.
260 break :v b.fmt("{}-dev.{}+{}", .{ version_string, commit_height, commit_id });266 break :v b.fmt("{}-dev.{}+{}", .{ version_string, commit_height, commit_id[1..] });
261 },267 },
262 else => {268 else => {
263 std.debug.print("Failed to parse `git describe` output: {}\n", .{git_describe});269 std.debug.print("Unexpected `git describe` output: {}\n", .{git_describe});
264 break :v version_string;270 break :v version_string;
265 },271 },
266 }272 }