| ... | @@ -86,13 +86,25 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { | ... | @@ -86,13 +86,25 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 86 | const v_type_s = iter.next().?; | 86 | const v_type_s = iter.next().?; |
| 87 | if (std.meta.stringToEnum(u.GitVersionType, v_type_s)) |v_type| { | 87 | if (std.meta.stringToEnum(u.GitVersionType, v_type_s)) |v_type| { |
| 88 | const ref = iter.rest(); | 88 | const ref = iter.rest(); |
| 89 | if ((try run_cmd(p, &[_][]const u8{"git", "rev-parse", ref})) > 0) { | 89 | if (try u.does_file_exist(pv)) { |
| | 90 | if (v_type == .branch) { |
| | 91 | _ = try run_cmd(pv, &[_][]const u8{"git", "fetch"}); |
| | 92 | _ = try run_cmd(pv, &[_][]const u8{"git", "pull"}); |
| | 93 | } |
| | 94 | moddir = pv; |
| | 95 | break :blk; |
| | 96 | } |
| | 97 | if ((try run_cmd(p, &[_][]const u8{"git", "checkout", ref})) > 0) { |
| 90 | u.assert(false, "fetch: git: {}: {} {} does not exist", .{d.path, @tagName(v_type), ref}); | 98 | u.assert(false, "fetch: git: {}: {} {} does not exist", .{d.path, @tagName(v_type), ref}); |
| | 99 | } else { |
| | 100 | _ = try run_cmd(p, &[_][]const u8{"git", "checkout", "-"}); |
| 91 | } | 101 | } |
| 92 | _ = try run_cmd(null, &[_][]const u8{"git", "clone", d.path, pv}); | 102 | _ = try run_cmd(null, &[_][]const u8{"git", "clone", d.path, pv}); |
| 93 | _ = try run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); | 103 | _ = try run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); |
| 94 | const pvd = try u.open_dir_absolute(pv); | 104 | if (v_type != .branch) { |
| 95 | try pvd.deleteTree(".git"); | 105 | const pvd = try u.open_dir_absolute(pv); |
| | 106 | try pvd.deleteTree(".git"); |
| | 107 | } |
| 96 | moddir = pv; | 108 | moddir = pv; |
| 97 | } | 109 | } |
| 98 | else { | 110 | else { |