authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-06 11:20:42 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-06 11:20:42 -07:00
log44c0c6c615900e9616e02514cc8b822afada9f0c
tree9bfd706cd35f48aac5a95d5d52dff4ab1db774d1
parent9f80f414a25e5abce9993b6f88efb2d0ca1da751

update lockfile format to version 2


3 files changed, 54 insertions(+), 20 deletions(-)

src/cmd/fetch.zig+2-1
......@@ -116,6 +116,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {
116116 defer fl.close();
117117
118118 const wl = fl.writer();
119 try wl.writeAll("2\n");
119120 for (list.items) |m| {
120121 if (m.dep) |md| {
121122 if (md.type == .local) {
......@@ -123,7 +124,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {
123124 }
124125 const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path });
125126 const version = if (md.version.len > 0) md.version else (try md.type.exact_version(mpath));
126 try wl.print("{s} {s} {s} {s}\n", .{ m.clean_path, @tagName(md.type), md.path, version });
127 try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version });
127128 }
128129 }
129130}
src/common.zig+40-8
......@@ -296,14 +296,46 @@ pub fn parse_lockfile(path: []const u8) ![]const [4][]const u8 {
296296 const max = std.math.maxInt(usize);
297297 const f = try std.fs.cwd().openFile(path, .{});
298298 const r = f.reader();
299 while (try r.readUntilDelimiterOrEofAlloc(gpa, '\n', max)) |line| {
300 var iter = std.mem.split(line, " ");
301 try list.append([4][]const u8{
302 iter.next().?,
303 iter.next().?,
304 iter.next().?,
305 iter.next().?,
306 });
299 var i: usize = 0;
300 var v: usize = 1;
301 while (try r.readUntilDelimiterOrEofAlloc(gpa, '\n', max)) |line| : (i += 1) {
302 if (i == 0 and std.mem.eql(u8, line, "2")) {
303 v = 2;
304 continue;
305 }
306 switch (v) {
307 1 => {
308 var iter = std.mem.split(line, " ");
309 try list.append([4][]const u8{
310 iter.next().?,
311 iter.next().?,
312 iter.next().?,
313 iter.next().?,
314 });
315 },
316 2 => {
317 var iter = std.mem.split(line, " ");
318 const asdep = u.Dep{
319 .type = std.meta.stringToEnum(u.DepType, iter.next().?).?,
320 .path = iter.next().?,
321 .version = iter.next().?,
322 .id = "",
323 .name = "",
324 .main = "",
325 .yaml = null,
326 .deps = &.{},
327 };
328 try list.append([4][]const u8{
329 try asdep.clean_path(),
330 @tagName(asdep.type),
331 asdep.path,
332 asdep.version,
333 });
334 },
335 else => {
336 u.assert(false, "invalid zigmod.lock version: {d}", .{v});
337 },
338 }
307339 }
308340 return list.toOwnedSlice();
309341}
zigmod.lock+12-11
......@@ -1,11 +1,12 @@
1v/git/github.com/yaml/libyaml/tag-0.2.5 git https://github.com/yaml/libyaml tag-0.2.5
2git/github.com/nektro/zig-ansi git https://github.com/nektro/zig-ansi commit-930ab1f
3git/github.com/ziglibs/known-folders git https://github.com/ziglibs/known-folders commit-f5e5fb8
4git/github.com/nektro/zig-licenses git https://github.com/nektro/zig-licenses commit-499bee6
5git/github.com/truemedian/zfetch git https://github.com/truemedian/zfetch commit-2cefe80
6git/github.com/truemedian/hzzp git https://github.com/truemedian/hzzp commit-2d30bdd
7git/github.com/alexnask/iguanaTLS git https://github.com/alexnask/iguanaTLS commit-0d39a36
8git/github.com/MasterQ32/zig-network git https://github.com/MasterQ32/zig-network commit-b9c9176
9git/github.com/MasterQ32/zig-uri git https://github.com/MasterQ32/zig-uri commit-f1896c6
10git/github.com/nektro/zig-json git https://github.com/nektro/zig-json commit-6599064
11git/github.com/nektro/zig-range git https://github.com/nektro/zig-range commit-890ca30
12
2git https://github.com/yaml/libyaml tag-0.2.5
3git https://github.com/nektro/zig-ansi commit-930ab1f
4git https://github.com/ziglibs/known-folders commit-f5e5fb8
5git https://github.com/nektro/zig-licenses commit-499bee6
6git https://github.com/truemedian/zfetch commit-2cefe80
7git https://github.com/truemedian/hzzp commit-2d30bdd
8git https://github.com/alexnask/iguanaTLS commit-0d39a36
9git https://github.com/MasterQ32/zig-network commit-b9c9176
10git https://github.com/MasterQ32/zig-uri commit-f1896c6
11git https://github.com/nektro/zig-json commit-6599064
12git https://github.com/nektro/zig-range commit-890ca30