From 7123877c9c335ca3890f3b95335a608cfe298060 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Mon, 26 Jan 2026 14:33:21 -0600 Subject: [PATCH 1/2] build: don't allow `/` in branch names This should fix CI failures like in PRs #10449 and #10450 that use long automatically-generated branch names. --- src/build/GitVersion.zig | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/build/GitVersion.zig b/src/build/GitVersion.zig index bfa9af821..658eca244 100644 --- a/src/build/GitVersion.zig +++ b/src/build/GitVersion.zig @@ -19,14 +19,18 @@ branch: []const u8, pub fn detect(b: *std.Build) !Version { // Execute a bunch of git commands to determine the automatic version. var code: u8 = 0; - const branch: []const u8 = b.runAllowFail( - &[_][]const u8{ "git", "-C", b.build_root.path orelse ".", "rev-parse", "--abbrev-ref", "HEAD" }, - &code, - .Ignore, - ) catch |err| switch (err) { - error.FileNotFound => return error.GitNotFound, - error.ExitCodeFailure => return error.GitNotRepository, - else => return err, + const branch: []const u8 = b: { + const tmp: []u8 = b.runAllowFail( + &[_][]const u8{ "git", "-C", b.build_root.path orelse ".", "rev-parse", "--abbrev-ref", "HEAD" }, + &code, + .Ignore, + ) catch |err| switch (err) { + error.FileNotFound => return error.GitNotFound, + error.ExitCodeFailure => return error.GitNotRepository, + else => return err, + }; + std.mem.replaceScalar(u8, tmp, '/', '-'); + break :b tmp; }; const short_hash = short_hash: { From 9172f6c5384eb221cf158a460144196a45b1cf50 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Mon, 26 Jan 2026 14:43:54 -0600 Subject: [PATCH 2/2] build: include comments on why '/' is removed --- src/build/GitVersion.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/build/GitVersion.zig b/src/build/GitVersion.zig index 658eca244..566fec2e9 100644 --- a/src/build/GitVersion.zig +++ b/src/build/GitVersion.zig @@ -29,6 +29,10 @@ pub fn detect(b: *std.Build) !Version { error.ExitCodeFailure => return error.GitNotRepository, else => return err, }; + // Replace any '/' with '-' as including slashes will mess up building + // the dist tarball - the tarball uses the branch as part of the + // name and including slashes means that the tarball will end up in + // subdirectories instead of where it's supposed to be. std.mem.replaceScalar(u8, tmp, '/', '-'); break :b tmp; };