| ... | ... | @@ -75,11 +75,10 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 75 | 75 | switch (d.type) { |
| 76 | 76 | .git => blk: { |
| 77 | 77 | if (!try u.does_file_exist(p)) { |
| 78 | | _ = try run_cmd(null, &[_][]const u8{"git", "clone", d.path, p}); |
| 78 | _ = try d.type.pull(d.path, p); |
| 79 | 79 | } |
| 80 | 80 | else { |
| 81 | | _ = try run_cmd(p, &[_][]const u8{"git", "fetch"}); |
| 82 | | _ = try run_cmd(p, &[_][]const u8{"git", "pull"}); |
| 81 | _ = try d.type.update(p, d.path); |
| 83 | 82 | } |
| 84 | 83 | if (d.version.len > 0) { |
| 85 | 84 | const iter = &std.mem.split(d.version, "-"); |
| ... | ... | @@ -88,19 +87,18 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 88 | 87 | const ref = iter.rest(); |
| 89 | 88 | if (try u.does_file_exist(pv)) { |
| 90 | 89 | if (v_type == .branch) { |
| 91 | | _ = try run_cmd(pv, &[_][]const u8{"git", "fetch"}); |
| 92 | | _ = try run_cmd(pv, &[_][]const u8{"git", "pull"}); |
| 90 | try d.type.update(p, d.path); |
| 93 | 91 | } |
| 94 | 92 | moddir = pv; |
| 95 | 93 | break :blk; |
| 96 | 94 | } |
| 97 | | if ((try run_cmd(p, &[_][]const u8{"git", "checkout", ref})) > 0) { |
| 95 | if ((try u.run_cmd(p, &[_][]const u8{"git", "checkout", ref})) > 0) { |
| 98 | 96 | u.assert(false, "fetch: git: {}: {} {} does not exist", .{d.path, @tagName(v_type), ref}); |
| 99 | 97 | } else { |
| 100 | | _ = try run_cmd(p, &[_][]const u8{"git", "checkout", "-"}); |
| 98 | _ = try u.run_cmd(p, &[_][]const u8{"git", "checkout", "-"}); |
| 101 | 99 | } |
| 102 | | _ = try run_cmd(null, &[_][]const u8{"git", "clone", d.path, pv}); |
| 103 | | _ = try run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); |
| 100 | _ = try u.run_cmd(null, &[_][]const u8{"git", "clone", d.path, pv}); |
| 101 | _ = try u.run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); |
| 104 | 102 | if (v_type != .branch) { |
| 105 | 103 | const pvd = try u.open_dir_absolute(pv); |
| 106 | 104 | try pvd.deleteTree(".git"); |
| ... | ... | @@ -114,10 +112,10 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 114 | 112 | }, |
| 115 | 113 | .hg => { |
| 116 | 114 | if (!try u.does_file_exist(p)) { |
| 117 | | _= try run_cmd(null, &[_][]const u8{"hg", "clone", d.path, p}); |
| 115 | _= try u.run_cmd(null, &[_][]const u8{"hg", "clone", d.path, p}); |
| 118 | 116 | } |
| 119 | 117 | else { |
| 120 | | _= try run_cmd(p, &[_][]const u8{"hg", "pull"}); |
| 118 | _= try u.run_cmd(p, &[_][]const u8{"hg", "pull"}); |
| 121 | 119 | } |
| 122 | 120 | }, |
| 123 | 121 | } |
| ... | ... | @@ -157,17 +155,6 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 157 | 155 | }; |
| 158 | 156 | } |
| 159 | 157 | |
| 160 | | fn run_cmd(dir: ?[]const u8, args: []const []const u8) !u32 { |
| 161 | | const result = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, }) catch |e| switch(e) { |
| 162 | | error.FileNotFound => { |
| 163 | | u.assert(false, "\"{}\" command not found", .{args[0]}); |
| 164 | | unreachable; |
| 165 | | }, |
| 166 | | else => return e, |
| 167 | | }; |
| 168 | | return result.term.Exited; |
| 169 | | } |
| 170 | | |
| 171 | 158 | fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) anyerror!void { |
| 172 | 159 | if (m.deps.len == 0 and tabs > 0) { |
| 173 | 160 | try w.print("null", .{}); |