| ... | ... | @@ -64,6 +64,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 64 | 64 | const moduledeps = &std.ArrayList(u.Module).init(gpa); |
| 65 | 65 | for (m.deps) |d| { |
| 66 | 66 | const p = try u.concat(&[_][]const u8{dir, "/", try d.clean_path()}); |
| 67 | const pv = try u.concat(&[_][]const u8{dir, "/v/", try d.clean_path(), "/", d.version}); |
| 67 | 68 | u.print("fetch: {}: {}: {}", .{m.name, @tagName(d.type), d.path}); |
| 68 | 69 | switch (d.type) { |
| 69 | 70 | .git => { |
| ... | ... | @@ -74,6 +75,23 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 74 | 75 | _ = try run_cmd(p, &[_][]const u8{"git", "fetch"}); |
| 75 | 76 | _ = try run_cmd(p, &[_][]const u8{"git", "pull"}); |
| 76 | 77 | } |
| 78 | if (d.version.len > 0) { |
| 79 | const iter = &std.mem.split(d.version, "-"); |
| 80 | const v_type_s = iter.next().?; |
| 81 | if (std.meta.stringToEnum(u.GitVersionType, v_type_s)) |v_type| { |
| 82 | const ref = iter.rest(); |
| 83 | if ((try run_cmd(p, &[_][]const u8{"git", "rev-parse", ref})) > 0) { |
| 84 | u.assert(false, "fetch: git: {}: {} {} does not exist", .{d.path, @tagName(v_type), ref}); |
| 85 | } |
| 86 | _ = try run_cmd(null, &[_][]const u8{"git", "clone", d.path, pv}); |
| 87 | _ = try run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); |
| 88 | const pvd = try std.fs.openDirAbsolute(pv, .{}); |
| 89 | try pvd.deleteTree(".git"); |
| 90 | } |
| 91 | else { |
| 92 | u.assert(false, "fetch: git: version type: '{}' on {} is invalid.", .{v_type_s, d.path}); |
| 93 | } |
| 94 | } |
| 77 | 95 | }, |
| 78 | 96 | .hg => { |
| 79 | 97 | if (!try u.does_file_exist(p)) { |