Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use version key for master install in zvm #20

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/install.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
}
}
Expand All @@ -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.?),
Expand Down
Loading