Don't directly execute Pijul from fetcher

dblsaiko
Mar 24, 2024, 8:31 PM
H5RKFV7YLV3QFY5HCQHGU7T232FPYMGWSBR3ABNGKMEAN5DS523AC

Dependencies

  • [2] U5AKEHEQ Fix build for Nix 2.19 to 2.21
  • [3] XGCRPWKL Move repo interaction into separate source file
  • [4] 3KEFKH5F Import existing code

Change contents

  • edit in src/repo.h at line 17
    [3.288]
    [3.288]
    std::string clone(const std::string_view &repoUrl,
    const nix::PathView &repoDir,
    const std::optional<std::string_view> &channel = {},
    const std::optional<std::string_view> &state = {});
  • replacement in src/repo.h at line 23
    [3.289][3.289:434]()
    std::string runPijul(nix::Strings args, std::optional<nix::Path> chdir = {}, std::optional<std::string> input = {}, bool isInteractive = false);
    [3.289]
    [3.434]
    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);
  • edit in src/repo.cpp at line 11
    [3.930]
    [3.930]
    #include <utility>
  • replacement in src/repo.cpp at line 23
    [3.1086][3.1086:1202]()
    std::string runPijul(Strings args, std::optional<Path> chdir, std::optional<std::string> input, bool isInteractive)
    [3.1086]
    [3.1202]
    std::string runPijul(Strings args, PathView chdir, std::optional<std::string> input = {}, bool isInteractive = {})
  • replacement in src/repo.cpp at line 31
    [3.1375][3.1375:1410]()
    .chdir = std::move(chdir),
    [3.1375]
    [3.1410]
    .chdir = Path(chdir),
  • edit in src/repo.cpp at line 41
    [3.1649]
    [3.1649]
    }
    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);
  • edit in src/repo.cpp at line 80
    [3.1652]
    [3.1652]
    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");
    }
  • edit in src/fetcher.cpp at line 27
    [3.3553]
    [3.3553]
    using nixpluginpijul::isRepoDirty;
    using nixpluginpijul::record;
    using nixpluginpijul::getTrackedFiles;
  • replacement in src/fetcher.cpp at line 167
    [2.965][2.965:1029](),[2.1029][4.3936:3937](),[4.3936][4.3936:3937](),[4.3937][2.1030:1146]()
    runPijul({"add", "--", std::string(path.rel())}, root);
    if (commitMsg)
    runPijul({"record", std::string(path.rel()), "-m", *commitMsg}, root, {}, true);
    [2.965]
    [2.1146]
    record(*commitMsg, *root, {path.rel()});
  • replacement in src/fetcher.cpp at line 175
    [4.4135][2.1224:1282](),[2.1282][4.4199:4223](),[4.4199][4.4199:4223](),[4.4223][2.1283:1370]()
    runPijul({"add", "--", std::string(file)}, root);
    if (commitMsg)
    runPijul({"record", std::string(file), "-m", *commitMsg}, root, {}, true);
    [4.4135]
    [2.1370]
    record(*commitMsg, *root, {file});
  • edit in src/fetcher.cpp at line 295
    [4.7224][4.7224:7485]()
    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);
    }
  • replacement in src/fetcher.cpp at line 296
    [4.7486][4.7486:7555]()
    args.emplace_back(repoUrl);
    args.push_back(repoDir);
    [4.7486]
    [4.7555]
    nixpluginpijul::clone(repoUrl, repoDir, channel, state);
  • edit in src/fetcher.cpp at line 298
    [4.7556][4.7556:7595]()
    runPijul(args, {}, {}, true);
  • edit in src/fetcher.cpp at line 330
    [4.8443][4.8443:8562]()
    const std::string &diffOutput = runPijul({"diff", "--json"}, std::string(path));
    bool dirty = false;
  • replacement in src/fetcher.cpp at line 331
    [4.8563][4.8563:8664]()
    if (!diffOutput.empty()) {
    const auto &json = nlohmann::json::parse(diffOutput);
    [4.8563]
    [4.8664]
    bool dirty = isRepoDirty(path);
  • edit in src/fetcher.cpp at line 333
    [4.8665][4.8665:8753]()
    if (!json.empty()) {
    dirty = true;
    }
    }
  • replacement in src/fetcher.cpp at line 343
    [4.9021][4.9021:9128]()
    auto files = tokenizeString<std::set<std::string>>(runPijul({"list"}, std::string(path)), "\n\r");
    [4.9021]
    [4.9128]
    auto files = getTrackedFiles(path);