From affde0ef54ff72de82c85f2667560d1160151d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=96R=C3=96SK=C5=90I=20Andr=C3=A1s?= Date: Sun, 13 Mar 2022 23:28:38 +0100 Subject: [PATCH] pijul depends: add channel support --- src/common.zig | 29 +++++++++++++++++++++++++++++ src/util/dep_type.zig | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/src/common.zig b/src/common.zig index 408742a..06247c2 100644 --- a/src/common.zig +++ b/src/common.zig @@ -206,6 +206,35 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! return p; }, .pijul => { + if (d.version.len > 0) { + const vers = u.parse_split(zigmod.DepType.Version.Pijul, "-").do(d.version) catch |e| switch (e) { + error.IterEmpty => unreachable, + error.NoMemberFound => { + const vtype = d.version[0..std.mem.indexOf(u8, d.version, "-").?]; + u.fail("pijul: version type '{s}' is invalid.", .{vtype}); + }, + }; + // this version is already pulled + if (try u.does_folder_exist(pv)) { + if (vers.id == .channel) { + if (options.update) { + // This does not work with pijul, have to use explicit channel name + // try d.type.update(options.alloc, pv, d.path); + if ((try u.run_cmd(options.alloc, pv, &.{ "pijul", "pull", "--all", "--from-channel", vers.string })) > 0) { + u.fail("pijul pull --from-channel {s}: did not succeed", .{vers.string}); + } + } + } + return pv; + } + // version has not pulled yet + if ((try u.run_cmd(options.alloc, null, &.{ "pijul", "clone", "--channel", vers.string, d.path, pv })) > 0) { + u.fail("pijul clone --channel: {s}: {s} {s} does not exist", .{ d.path, @tagName(vers.id), vers.string }); + } + return pv; + } + + // no version string if (!try u.does_folder_exist(p)) { try d.type.pull(options.alloc, d.path, p); } else { diff --git a/src/util/dep_type.zig b/src/util/dep_type.zig index 9def3c3..e5c7dbd 100644 --- a/src/util/dep_type.zig +++ b/src/util/dep_type.zig @@ -117,6 +117,7 @@ pub const DepType = enum { git: Git, hg: void, http: void, + pijul: Pijul, pub const Git = enum { branch, @@ -131,5 +132,8 @@ pub const DepType = enum { }; } }; + pub const Pijul = enum { + channel, + }; }; };