| ... | @@ -86,18 +86,18 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { | ... | @@ -86,18 +86,18 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 86 | // no op | 86 | // no op |
| 87 | }, | 87 | }, |
| 88 | .git => blk: { | 88 | .git => blk: { |
| 89 | if (!try u.does_file_exist(p)) { | 89 | if (!try u.does_folder_exist(p)) { |
| 90 | _ = try d.type.pull(d.path, p); | 90 | try d.type.pull(d.path, p); |
| 91 | } | 91 | } |
| 92 | else { | 92 | else { |
| 93 | _ = try d.type.update(p, d.path); | 93 | try d.type.update(p, d.path); |
| 94 | } | 94 | } |
| 95 | if (d.version.len > 0) { | 95 | if (d.version.len > 0) { |
| 96 | const iter = &std.mem.split(d.version, "-"); | 96 | const iter = &std.mem.split(d.version, "-"); |
| 97 | const v_type_s = iter.next().?; | 97 | const v_type_s = iter.next().?; |
| 98 | if (std.meta.stringToEnum(u.GitVersionType, v_type_s)) |v_type| { | 98 | if (std.meta.stringToEnum(u.GitVersionType, v_type_s)) |v_type| { |
| 99 | const ref = iter.rest(); | 99 | const ref = iter.rest(); |
| 100 | if (try u.does_file_exist(pv)) { | 100 | if (try u.does_folder_exist(pv)) { |
| 101 | if (v_type == .branch) { | 101 | if (v_type == .branch) { |
| 102 | try d.type.update(p, d.path); | 102 | try d.type.update(p, d.path); |
| 103 | } | 103 | } |
| ... | @@ -109,7 +109,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { | ... | @@ -109,7 +109,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 109 | } else { | 109 | } else { |
| 110 | _ = try u.run_cmd(p, &[_][]const u8{"git", "checkout", "-"}); | 110 | _ = try u.run_cmd(p, &[_][]const u8{"git", "checkout", "-"}); |
| 111 | } | 111 | } |
| 112 | _ = try u.run_cmd(null, &[_][]const u8{"git", "clone", d.path, pv}); | 112 | try d.type.pull(d.path, pv); |
| 113 | _ = try u.run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); | 113 | _ = try u.run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); |
| 114 | if (v_type != .branch) { | 114 | if (v_type != .branch) { |
| 115 | const pvd = try u.open_dir_absolute(pv); | 115 | const pvd = try u.open_dir_absolute(pv); |
| ... | @@ -123,19 +123,37 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { | ... | @@ -123,19 +123,37 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 123 | } | 123 | } |
| 124 | }, | 124 | }, |
| 125 | .hg => { | 125 | .hg => { |
| 126 | if (!try u.does_file_exist(p)) { | 126 | if (!try u.does_folder_exist(p)) { |
| 127 | _ = try d.type.pull(d.path, p); | 127 | try d.type.pull(d.path, p); |
| 128 | } | 128 | } |
| 129 | else { | 129 | else { |
| 130 | _ = try d.type.update(p, d.path); | 130 | try d.type.update(p, d.path); |
| 131 | } | 131 | } |
| 132 | }, | 132 | }, |
| 133 | .http => { | 133 | .http => blk: { |
| | 134 | if (try u.does_folder_exist(pv)) { |
| | 135 | moddir = pv; |
| | 136 | break :blk; |
| | 137 | } |
| 134 | const file_name = try u.last(try u.split(d.path, "/")); | 138 | const file_name = try u.last(try u.split(d.path, "/")); |
| 135 | if (try u.does_file_exist(p)) { | 139 | if (d.version.len > 0) { |
| | 140 | const file_path = try std.fs.path.join(gpa, &[_][]const u8{pv, file_name}); |
| | 141 | try d.type.pull(d.path, pv); |
| | 142 | if (try u.validate_hash(try u.last(try u.split(pv, "/")), file_path)) { |
| | 143 | try std.fs.deleteFileAbsolute(file_path); |
| | 144 | moddir = pv; |
| | 145 | break :blk; |
| | 146 | } |
| | 147 | try u.rm_recv(pv); |
| | 148 | u.assert(false, "{} does not match hash {}", .{d.path, d.version}); |
| | 149 | break :blk; |
| | 150 | } |
| | 151 | if (try u.does_folder_exist(p)) { |
| 136 | try u.rm_recv(p); | 152 | try u.rm_recv(p); |
| 137 | } | 153 | } |
| 138 | _ = try d.type.pull(d.path, p); | 154 | const file_path = try std.fs.path.join(gpa, &[_][]const u8{p, file_name}); |
| | 155 | try d.type.pull(d.path, p); |
| | 156 | try std.fs.deleteFileAbsolute(file_path); |
| 139 | }, | 157 | }, |
| 140 | } | 158 | } |
| 141 | switch (d.type) { | 159 | switch (d.type) { |