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 "")
4646 if(NOT GIT_TAG VERSION_EQUAL ZIG_VERSION)
4747 message(SEND_ERROR "Zig version (${ZIG_VERSION}) does not match Git tag (${GIT_TAG}).")
4848 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(.+)$")
5050 # Untagged pre-release. The Zig version is updated to include the number of commits
5151 # since the last tagged version and the commit hash. The version is formatted in
5252 # accordance with the https://semver.org specification.
build.zig+8-2
......@@ -256,11 +256,17 @@ pub fn build(b: *Builder) !void {
256256 std.process.exit(1);
257257 }
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
259265 // 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..] });
261267 },
262268 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});
264270 break :v version_string;
265271 },
266272 }