| ... | @@ -75,11 +75,10 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { | ... | @@ -75,11 +75,10 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 75 | switch (d.type) { | 75 | switch (d.type) { |
| 76 | .git => blk: { | 76 | .git => blk: { |
| 77 | if (!try u.does_file_exist(p)) { | 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 | else { | 80 | else { |
| 81 | _ = try run_cmd(p, &[_][]const u8{"git", "fetch"}); | 81 | _ = try d.type.update(p, d.path); |
| 82 | _ = try run_cmd(p, &[_][]const u8{"git", "pull"}); | | |
| 83 | } | 82 | } |
| 84 | if (d.version.len > 0) { | 83 | if (d.version.len > 0) { |
| 85 | const iter = &std.mem.split(d.version, "-"); | 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,19 +87,18 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 88 | const ref = iter.rest(); | 87 | const ref = iter.rest(); |
| 89 | if (try u.does_file_exist(pv)) { | 88 | if (try u.does_file_exist(pv)) { |
| 90 | if (v_type == .branch) { | 89 | if (v_type == .branch) { |
| 91 | _ = try run_cmd(pv, &[_][]const u8{"git", "fetch"}); | 90 | try d.type.update(p, d.path); |
| 92 | _ = try run_cmd(pv, &[_][]const u8{"git", "pull"}); | | |
| 93 | } | 91 | } |
| 94 | moddir = pv; | 92 | moddir = pv; |
| 95 | break :blk; | 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 | u.assert(false, "fetch: git: {}: {} {} does not exist", .{d.path, @tagName(v_type), ref}); | 96 | u.assert(false, "fetch: git: {}: {} {} does not exist", .{d.path, @tagName(v_type), ref}); |
| 99 | } else { | 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}); | 100 | _ = try u.run_cmd(null, &[_][]const u8{"git", "clone", d.path, pv}); |
| 103 | _ = try run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); | 101 | _ = try u.run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); |
| 104 | if (v_type != .branch) { | 102 | if (v_type != .branch) { |
| 105 | const pvd = try u.open_dir_absolute(pv); | 103 | const pvd = try u.open_dir_absolute(pv); |
| 106 | try pvd.deleteTree(".git"); | 104 | try pvd.deleteTree(".git"); |
| ... | @@ -114,10 +112,10 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { | ... | @@ -114,10 +112,10 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 114 | }, | 112 | }, |
| 115 | .hg => { | 113 | .hg => { |
| 116 | if (!try u.does_file_exist(p)) { | 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 | else { | 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,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 | fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) anyerror!void { | 158 | fn print_deps(w: std.fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32) anyerror!void { |
| 172 | if (m.deps.len == 0 and tabs > 0) { | 159 | if (m.deps.len == 0 and tabs > 0) { |
| 173 | try w.print("null", .{}); | 160 | try w.print("null", .{}); |