H5RKFV7YLV3QFY5HCQHGU7T232FPYMGWSBR3ABNGKMEAN5DS523AC
std::string runPijul(nix::Strings args, std::optional<nix::Path> chdir = {}, std::optional<std::string> input = {}, bool isInteractive = false);
std::string record(const std::string_view &message, const nix::PathView &repoDir, const std::vector<nix::PathView> &paths = {});
bool isRepoDirty(const nix::PathView &repoDir);
std::set<std::string> getTrackedFiles(const nix::PathView &repoDir);
}
std::string record(const std::string_view &message, const PathView &chdir, const std::vector<std::string_view> &paths)
{
Strings args{"record", "--message"};
args.emplace_back(message);
args.emplace_back("--");
for (auto &s : paths) {
args.emplace_back(s);
}
return runPijul(args, chdir, {}, true);
}
std::string clone(const std::string_view &repoUrl,
const std::string_view &repoDir,
const std::optional<std::string_view> &channel,
const std::optional<std::string_view> &state)
{
Strings args{"clone"s};
if (channel) {
args.push_back("--channel"s);
args.emplace_back(*channel);
}
if (state) {
args.push_back("--state"s);
args.emplace_back(*state);
}
args.emplace_back(repoUrl);
args.emplace_back(repoDir);
return runPijul(args, {}, {}, true);
bool isRepoDirty(const PathView &chdir = {})
{
const std::string &diffOutput = runPijul({"diff", "--json"}, chdir);
bool dirty = false;
if (!diffOutput.empty()) {
const auto &json = nlohmann::json::parse(diffOutput);
if (!json.empty()) {
dirty = true;
}
}
return dirty;
}
std::set<std::string> getTrackedFiles(const nix::PathView &repoDir)
{
auto output = runPijul({"list"}, repoDir);
return tokenizeString<std::set<std::string>>(output, "\n\r");
}
runPijul({"add", "--", std::string(path.rel())}, root);
if (commitMsg)
runPijul({"record", std::string(path.rel()), "-m", *commitMsg}, root, {}, true);
record(*commitMsg, *root, {path.rel()});
runPijul({"add", "--", std::string(file)}, root);
if (commitMsg)
runPijul({"record", std::string(file), "-m", *commitMsg}, root, {}, true);
record(*commitMsg, *root, {file});