Commit ec102951cb

g-w1 <jacoblevgw@gmail.com>
2020-12-25 23:18:44
remove git diff dirty changes feature from build.zig
1 parent 1322a73
Changed files (1)
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));