authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 00:53:23 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-18 00:53:23 -07:00
logec980d58a02151b3f39508be69d4ffea588b0850
tree7089fb490afc945c68425187491d682c7733a210
parent014d13f8a3ca27359ee2b48b1e83e60c6df78f33

remove dependence on non-const temporaries


2 files changed, 6 insertions(+), 3 deletions(-)

src/cmd/fetch.zig+4-2
......@@ -109,13 +109,14 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
109109
110110 try w.writeAll("pub const package_data = struct {\n");
111111 var duped = std.ArrayList(zigmod.Module).init(alloc);
112 var done = std.ArrayList(zigmod.Module).init(alloc);
112113 for (list.items) |mod| {
113114 if (mod.type == .system_lib or mod.type == .framework) {
114115 continue;
115116 }
116117 try duped.append(mod);
117118 }
118 try print_pkg_data_to(w, &duped, &std.ArrayList(zigmod.Module).init(alloc));
119 try print_pkg_data_to(w, &duped, &done);
119120 try w.writeAll("};\n\n");
120121
121122 try w.writeAll("pub const packages = ");
......@@ -159,7 +160,8 @@ fn diff_lockfile(alloc: std.mem.Allocator) !void {
159160
160161 if (try u.does_folder_exist(".git")) {
161162 const result = try u.run_cmd_raw(alloc, null, &.{ "git", "diff", "zigmod.lock" });
162 const r = std.io.fixedBufferStream(result.stdout).reader();
163 var stdout = std.io.fixedBufferStream(result.stdout);
164 const r = stdout.reader();
163165 while (try r.readUntilDelimiterOrEofAlloc(alloc, '\n', max)) |line| {
164166 if (std.mem.startsWith(u8, line, "@@")) break;
165167 }
src/cmd/generate.zig+2-1
......@@ -189,13 +189,14 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
189189
190190 try w.writeAll("pub const package_data = struct {\n");
191191 var duped = std.ArrayList(zigmod.Module).init(alloc);
192 var done = std.ArrayList(zigmod.Module).init(alloc);
192193 for (list) |mod| {
193194 if (mod.type == .system_lib or mod.type == .framework) {
194195 continue;
195196 }
196197 try duped.append(mod);
197198 }
198 try print_pkg_data_to(w, alloc, cachepath, &duped, &std.ArrayList(zigmod.Module).init(alloc));
199 try print_pkg_data_to(w, alloc, cachepath, &duped, &done);
199200 try w.writeAll("};\n\n");
200201
201202 try w.writeAll("pub const packages = ");