authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-03-07 21:20:52 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-03-07 21:20:52 -08:00
log2722fd1f247a5db7f6371dbaa778fa0d59510b9b
treedd1fd76f12b9ce48323b4612e94bb1b6d96ad199
parent674b25fad692565bf10d69fab669be52171d5bf3

add DepType.isLocal


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

src/cmd/fetch.zig+1-4
......@@ -138,10 +138,7 @@ fn create_lockfile(alloc: std.mem.Allocator, list: *std.ArrayList(zigmod.Module)
138138 try wl.writeAll("2\n");
139139 for (list.items) |m| {
140140 if (m.dep) |md| {
141 if (md.type == .local) {
142 continue;
143 }
144 if (md.type == .system_lib) continue;
141 if (md.type.isLocal()) continue;
145142 const mpath = try std.fs.path.join(alloc, &.{ path, m.clean_path });
146143 const version = try md.exact_version(mpath);
147144 try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version });
src/common.zig+2-2
......@@ -108,7 +108,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !
108108 const p = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path() });
109109 const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v() });
110110
111 const nocache = d.type == .local or d.type == .system_lib;
111 const nocache = d.type.isLocal();
112112 if (!nocache and u.list_contains(options.already_fetched.items, p)) return p;
113113 if (!nocache and u.list_contains(options.already_fetched.items, pv)) return pv;
114114
......@@ -223,7 +223,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO
223223 const modpath = try get_modpath(cachepath, d.*, options);
224224 const moddir = if (std.mem.eql(u8, modpath, "files") or modpath.len == 0) try std.fs.cwd().openDir(cachepath, .{}) else try std.fs.cwd().openDir(modpath, .{});
225225
226 const nocache = d.type == .local or d.type == .system_lib;
226 const nocache = d.type.isLocal();
227227 if (!nocache) try options.already_fetched.append(modpath);
228228
229229 switch (d.type) {
src/util/dep_type.zig+10
......@@ -89,6 +89,16 @@ pub const DepType = enum {
8989 };
9090 }
9191
92 pub fn isLocal(self: DepType) bool {
93 return switch (self) {
94 .local => true,
95 .system_lib => true,
96 .git => false,
97 .hg => false,
98 .http => false,
99 };
100 }
101
92102 pub const GitVersion = enum {
93103 branch,
94104 tag,