Skip to content

Commit

Permalink
pijul depends: add channel support
Browse files Browse the repository at this point in the history
  • Loading branch information
voroskoi committed Mar 14, 2022
1 parent faf6ddc commit affde0e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/common.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/util/dep_type.zig
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub const DepType = enum {
git: Git,
hg: void,
http: void,
pijul: Pijul,

pub const Git = enum {
branch,
Expand All @@ -131,5 +132,8 @@ pub const DepType = enum {
};
}
};
pub const Pijul = enum {
channel,
};
};
};

0 comments on commit affde0e

Please sign in to comment.