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

remove `git diff` feature from build.zig
This commit is contained in:
Andrew Kelley 2020-12-25 16:39:23 -08:00 committed by GitHub
commit 864a5442f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -234,18 +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| {
std.debug.print("Error executing git diff: {}", .{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")) {
@ -254,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));