authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-25 16:39:23-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-12-25 16:39:23-08:00
log864a5442f1d1a61c29fd6390f4a1c86ce301ceb2
tree08ba7a6aa5007c3a5eab5ce52b61dca73bbe5c6c
parentc99c6c0a68bb1c32123a027c274b165b3891e88b
parentec102951cb9ef7f9859ff719fc77afd264d66a5b
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #7542 from g-w1/build-diff-large

remove `git diff` feature from build.zig

1 files changed, 2 insertions(+), 14 deletions(-)

build.zig+2-14
......@@ -234,18 +234,6 @@ pub fn build(b: *Builder) !void {
234234 break :v version_string;
235235 };
236236 const git_sha_trimmed = mem.trim(u8, git_sha_untrimmed, " \n\r");
237 // Detect dirty changes.
238 const diff_untrimmed = b.execAllowFail(&[_][]const u8{
239 "git", "-C", b.build_root, "diff", "HEAD",
240 }, &code, .Ignore) catch |err| {
241 std.debug.print("Error executing git diff: {}", .{err});
242 std.process.exit(1);
243 };
244 const trimmed_diff = mem.trim(u8, diff_untrimmed, " \n\r");
245 const dirty_suffix = if (trimmed_diff.len == 0) "" else s: {
246 const dirty_hash = std.hash.Wyhash.hash(0, trimmed_diff);
247 break :s b.fmt("dirty{x}", .{@truncate(u32, dirty_hash)});
248 };
249237
250238 // This will look like e.g. "0.7.0^0" for a tag commit.
251239 if (mem.endsWith(u8, git_sha_trimmed, "^0")) {
......@@ -254,9 +242,9 @@ pub fn build(b: *Builder) !void {
254242 std.debug.print("Expected git tag '{}', found '{}'\n", .{ version_string, git_ver_string });
255243 std.process.exit(1);
256244 }
257 break :v b.fmt("{}{}", .{ version_string, dirty_suffix });
245 break :v b.fmt("{}", .{version_string});
258246 } else {
259 break :v b.fmt("{}+{}{}", .{ version_string, git_sha_trimmed, dirty_suffix });
247 break :v b.fmt("{}+{}", .{ version_string, git_sha_trimmed });
260248 }
261249 };
262250 exe.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));