From 1322a7314139206b3b67240b826d02821cc87a7f Mon Sep 17 00:00:00 2001 From: g-w1 Date: Thu, 24 Dec 2020 18:28:13 -0500 Subject: [PATCH 1/2] make if the diff too large just default to dirty_diff_too_big as the diff --- build.zig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index b6dfbf547f77..11ac83821e89 100644 --- a/build.zig +++ b/build.zig @@ -237,9 +237,13 @@ pub fn build(b: *Builder) !void { // Detect dirty changes. const diff_untrimmed = b.execAllowFail(&[_][]const u8{ "git", "-C", b.build_root, "diff", "HEAD", - }, &code, .Ignore) catch |err| { - std.debug.print("Error executing git diff: {}", .{err}); - std.process.exit(1); + }, &code, .Ignore) catch |err| switch (err) { + // when there is a big diff, usually after resolving merge conflicts, but before a commit + error.StreamTooLong => "dirty_diff_too_big", + else => { + std.debug.print("Error executing git diff: {}\n", .{err}); + std.process.exit(1); + }, }; const trimmed_diff = mem.trim(u8, diff_untrimmed, " \n\r"); const dirty_suffix = if (trimmed_diff.len == 0) "" else s: { From ec102951cb9ef7f9859ff719fc77afd264d66a5b Mon Sep 17 00:00:00 2001 From: g-w1 Date: Fri, 25 Dec 2020 17:18:44 -0500 Subject: [PATCH 2/2] remove git diff dirty changes feature from build.zig --- build.zig | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/build.zig b/build.zig index 11ac83821e89..bef3b3b58faa 100644 --- a/build.zig +++ b/build.zig @@ -234,22 +234,6 @@ pub fn build(b: *Builder) !void { break :v version_string; }; const git_sha_trimmed = mem.trim(u8, git_sha_untrimmed, " \n\r"); - // Detect dirty changes. - const diff_untrimmed = b.execAllowFail(&[_][]const u8{ - "git", "-C", b.build_root, "diff", "HEAD", - }, &code, .Ignore) catch |err| switch (err) { - // when there is a big diff, usually after resolving merge conflicts, but before a commit - error.StreamTooLong => "dirty_diff_too_big", - else => { - std.debug.print("Error executing git diff: {}\n", .{err}); - std.process.exit(1); - }, - }; - const trimmed_diff = mem.trim(u8, diff_untrimmed, " \n\r"); - const dirty_suffix = if (trimmed_diff.len == 0) "" else s: { - const dirty_hash = std.hash.Wyhash.hash(0, trimmed_diff); - break :s b.fmt("dirty{x}", .{@truncate(u32, dirty_hash)}); - }; // This will look like e.g. "0.7.0^0" for a tag commit. if (mem.endsWith(u8, git_sha_trimmed, "^0")) { @@ -258,9 +242,9 @@ pub fn build(b: *Builder) !void { std.debug.print("Expected git tag '{}', found '{}'\n", .{ version_string, git_ver_string }); std.process.exit(1); } - break :v b.fmt("{}{}", .{ version_string, dirty_suffix }); + break :v b.fmt("{}", .{version_string}); } else { - break :v b.fmt("{}+{}{}", .{ version_string, git_sha_trimmed, dirty_suffix }); + break :v b.fmt("{}+{}", .{ version_string, git_sha_trimmed }); } }; exe.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));