| ... | ... | @@ -93,33 +93,33 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 93 | 93 | try d.type.update(p, d.path); |
| 94 | 94 | } |
| 95 | 95 | if (d.version.len > 0) { |
| 96 | | const iter = &std.mem.split(d.version, "-"); |
| 97 | | const v_type_s = iter.next().?; |
| 98 | | if (std.meta.stringToEnum(u.GitVersionType, v_type_s)) |v_type| { |
| 99 | | const ref = iter.rest(); |
| 100 | | if (try u.does_folder_exist(pv)) { |
| 101 | | if (v_type == .branch) { |
| 102 | | try d.type.update(p, d.path); |
| 103 | | } |
| 104 | | moddir = pv; |
| 105 | | break :blk; |
| 106 | | } |
| 107 | | if ((try u.run_cmd(p, &[_][]const u8{"git", "checkout", ref})) > 0) { |
| 108 | | u.assert(false, "fetch: git: {}: {} {} does not exist", .{d.path, @tagName(v_type), ref}); |
| 109 | | } else { |
| 110 | | _ = try u.run_cmd(p, &[_][]const u8{"git", "checkout", "-"}); |
| 111 | | } |
| 112 | | try d.type.pull(d.path, pv); |
| 113 | | _ = try u.run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); |
| 114 | | if (v_type != .branch) { |
| 115 | | const pvd = try u.open_dir_absolute(pv); |
| 116 | | try pvd.deleteTree(".git"); |
| 96 | const vers = u.parse_split(u.GitVersionType, "-").do(d.version) catch |e| switch (e) { |
| 97 | error.IterEmpty => unreachable, |
| 98 | error.NoMemberFound => { |
| 99 | const vtype = d.version[0..std.mem.indexOf(u8, d.version, "-").?]; |
| 100 | u.assert(false, "fetch: git: version type '{}' is invalid.", .{vtype}); |
| 101 | unreachable; |
| 102 | }, |
| 103 | }; |
| 104 | if (try u.does_folder_exist(pv)) { |
| 105 | if (vers.id == .branch) { |
| 106 | try d.type.update(p, d.path); |
| 117 | 107 | } |
| 118 | 108 | moddir = pv; |
| 109 | break :blk; |
| 119 | 110 | } |
| 120 | | else { |
| 121 | | u.assert(false, "fetch: git: version type: '{}' on {} is invalid.", .{v_type_s, d.path}); |
| 111 | if ((try u.run_cmd(p, &[_][]const u8{"git", "checkout", vers.string})) > 0) { |
| 112 | u.assert(false, "fetch: git: {}: {} {} does not exist", .{d.path, @tagName(vers.id), vers.string}); |
| 113 | } else { |
| 114 | _ = try u.run_cmd(p, &[_][]const u8{"git", "checkout", "-"}); |
| 122 | 115 | } |
| 116 | try d.type.pull(d.path, pv); |
| 117 | _ = try u.run_cmd(pv, &[_][]const u8{"git", "checkout", vers.string}); |
| 118 | if (vers.id != .branch) { |
| 119 | const pvd = try u.open_dir_absolute(pv); |
| 120 | try pvd.deleteTree(".git"); |
| 121 | } |
| 122 | moddir = pv; |
| 123 | 123 | } |
| 124 | 124 | }, |
| 125 | 125 | .hg => { |