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 17c0dc5 commit e5fdded
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 @@ -208,6 +208,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.PijulVersion, "-").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 @@ -123,4 +123,8 @@ pub const DepType = enum {
};
}
};

pub const PijulVersion = enum {
channel,
};
};

0 comments on commit e5fdded

Please sign in to comment.