make if the diff too large just default to dirty_diff_too_big as the diff

This commit is contained in:
g-w1
2020-12-24 18:28:13 -05:00
parent e18abab55a
commit 1322a73141

View File

@@ -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: {