From f085ecf949a68a86d2a94f7333c8fb3c3bd71314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hendrik=20Niel=C3=A4nder?= Date: Mon, 6 Nov 2023 23:14:55 +0100 Subject: [PATCH] fix: master install --- src/install.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/install.zig b/src/install.zig index f2c2cd0..118feb0 100644 --- a/src/install.zig +++ b/src/install.zig @@ -57,12 +57,16 @@ fn fetchVersionData(allocator: Allocator, requested_version: []const u8, sub_key // const key = key_ptr.*; if (std.mem.eql(u8, entry.key_ptr.*, requested_version)) { // Initialize fields with null. + var version: ?[]const u8 = "not_set"; var date: ?[]const u8 = null; var tarball: ?[]const u8 = null; var shasum: ?[]const u8 = null; var valObj = entry.value_ptr.*.object.iterator(); while (valObj.next()) |value| { + if (std.mem.eql(u8, value.key_ptr.*, "version")) { + version = value.value_ptr.*.string; + } if (std.mem.eql(u8, value.key_ptr.*, "date")) { date = value.value_ptr.*.string; } else if (std.mem.eql(u8, value.key_ptr.*, sub_key)) { @@ -71,7 +75,8 @@ fn fetchVersionData(allocator: Allocator, requested_version: []const u8, sub_key while (nestedObj.next()) |nestedValue| { if (std.mem.eql(u8, nestedValue.key_ptr.*, "tarball")) { tarball = nestedValue.value_ptr.*.string; - } else if (std.mem.eql(u8, nestedValue.key_ptr.*, "shasum")) { + } + if (std.mem.eql(u8, nestedValue.key_ptr.*, "shasum")) { shasum = nestedValue.value_ptr.*.string; } } @@ -83,9 +88,10 @@ fn fetchVersionData(allocator: Allocator, requested_version: []const u8, sub_key return Error.MissingExpectedFields; } + const version_name = if (std.mem.eql(u8, requested_version, "master")) version.? else requested_version; // Create the Version struct. return Version{ - .name = try allocator.dupe(u8, requested_version), + .name = try allocator.dupe(u8, version_name), .date = try allocator.dupe(u8, date.?), .tarball = try allocator.dupe(u8, tarball.?), .shasum = try allocator.dupe(u8, shasum.?),