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)...@@ -138,10 +138,7 @@ fn create_lockfile(alloc: std.mem.Allocator, list: *std.ArrayList(zigmod.Module)
138 try wl.writeAll("2\n");138 try wl.writeAll("2\n");
139 for (list.items) |m| {139 for (list.items) |m| {
140 if (m.dep) |md| {140 if (m.dep) |md| {
141 if (md.type == .local) {141 if (md.type.isLocal()) continue;
142 continue;
143 }
144 if (md.type == .system_lib) continue;
145 const mpath = try std.fs.path.join(alloc, &.{ path, m.clean_path });142 const mpath = try std.fs.path.join(alloc, &.{ path, m.clean_path });
146 const version = try md.exact_version(mpath);143 const version = try md.exact_version(mpath);
147 try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version });144 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) !...@@ -108,7 +108,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !
108 const p = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path() });108 const p = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path() });
109 const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v() });109 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();
112 if (!nocache and u.list_contains(options.already_fetched.items, p)) return p;112 if (!nocache and u.list_contains(options.already_fetched.items, p)) return p;
113 if (!nocache and u.list_contains(options.already_fetched.items, pv)) return pv;113 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...@@ -223,7 +223,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO
223 const modpath = try get_modpath(cachepath, d.*, options);223 const modpath = try get_modpath(cachepath, d.*, options);
224 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, .{});224 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();
227 if (!nocache) try options.already_fetched.append(modpath);227 if (!nocache) try options.already_fetched.append(modpath);
228228
229 switch (d.type) {229 switch (d.type) {
src/util/dep_type.zig+10
...@@ -89,6 +89,16 @@ pub const DepType = enum {...@@ -89,6 +89,16 @@ pub const DepType = enum {
89 };89 };
90 }90 }
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
92 pub const GitVersion = enum {102 pub const GitVersion = enum {
93 branch,103 branch,
94 tag,104 tag,