From 1188d0979cfdf1cd3d2296c07c2ca6a798663b7c Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 29 May 2026 05:30:35 -0700 Subject: [PATCH] cmd/generate: handle when dep is a commit-SHA --- src/util/module.zig | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/util/module.zig b/src/util/module.zig index 2ee54fde249c395afec9bf25157e96c40e66d533..b56434ca423ef12250b4bae3e139f7cfb0b358c2 100644 --- a/src/util/module.zig +++ b/src/util/module.zig @@ -176,7 +176,19 @@ pub const Module = struct { return switch (sub) { .local, .system_lib, .framework => unreachable, .git => { - if (options.lock == null) return try u.git_rev_HEAD(alloc, mdir); + if (options.lock == null) { + return u.git_rev_HEAD(alloc, mdir) catch |err| switch (err) { + error.ENOENT, error.NotAGitRepo => { + const cpath = extras.trimPrefixEnsure(self.clean_path, "v/") orelse return err; + var iter = std.mem.splitScalar(u8, cpath, '/'); + while (iter.next()) |segment| { + if (iter.peek() == null) return segment; + } + unreachable; + }, + else => |e| e, + }; + } for (options.lock.?) |item| { if (!std.mem.eql(u8, item[1], "git")) continue; if (!std.mem.eql(u8, item[2], self.dep.?.path)) continue; -- 2.54.0