Skip to content

Commit

Permalink
Merge pull request ziglang#7542 from g-w1/build-diff-large
Browse files Browse the repository at this point in the history
remove `git diff` feature from build.zig
  • Loading branch information
andrewrk authored Dec 26, 2020
2 parents c99c6c0 + ec10295 commit 864a544
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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));
Expand Down

0 comments on commit 864a544

Please sign in to comment.