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 13, 2022
1 parent faf6ddc commit ee06925
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/common.zig
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,31 @@ 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) {
try d.type.update(options.alloc, pv, d.path);
}
}
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 ee06925

Please sign in to comment.