authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-20 15:53:30 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-20 15:53:30 -08:00
log90cb4cc5acf8f281649ee7c305e73a2bafc68503
tree31cbcfa78d96841f8ab9ccea523952b6c117383a
parenta53fd2f725c29ab5e5de65d300dee48d22bfe023

fetch: fix git version pinning


1 files changed, 15 insertions(+), 3 deletions(-)

src/cmd_fetch.zig+15-3
...@@ -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 {