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