summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/other_tools/just_mr/main.cpp17
-rw-r--r--src/other_tools/repo_map/repos_to_setup_map.cpp90
-rw-r--r--src/other_tools/root_maps/TARGETS1
-rw-r--r--src/other_tools/root_maps/distdir_git_map.cpp26
-rw-r--r--src/other_tools/root_maps/distdir_git_map.hpp11
-rw-r--r--test/end-to-end/just-mr/install-roots.sh2
6 files changed, 74 insertions, 73 deletions
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index e331a063..af6589bc 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -787,9 +787,16 @@ void DefaultReachableRepositories(
(*resolved_repo_desc)->Get("sha256", Expression::none_t{});
auto repo_desc_sha512 =
(*resolved_repo_desc)->Get("sha512", Expression::none_t{});
- auto repo_desc_ignore_special =
- (*resolved_repo_desc)
- ->Get("ignore_special", Expression::none_t{});
+ // check "special" pragma
+ auto repo_desc_pragma = (*resolved_repo_desc)->At("pragma");
+ auto pragma_special =
+ repo_desc_pragma ? repo_desc_pragma->get()->At("special")
+ : std::nullopt;
+ auto pragma_special_value =
+ pragma_special and pragma_special->get()->IsString()
+ ? std::make_optional(pragma_special->get()->String())
+ : std::nullopt;
+
ArchiveRepoInfo archive_info = {
.archive = {.content = repo_desc_content->get()->String(),
.distfile =
@@ -810,9 +817,7 @@ void DefaultReachableRepositories(
.origin_from_distdir = false},
.repo_type = repo_type_str,
.subdir = subdir.empty() ? "." : subdir.string(),
- .ignore_special = repo_desc_ignore_special->IsBool()
- ? repo_desc_ignore_special->Bool()
- : false};
+ .ignore_special = pragma_special_value == "ignore"};
// add to list
repos_to_fetch.emplace_back(std::move(archive_info));
}
diff --git a/src/other_tools/repo_map/repos_to_setup_map.cpp b/src/other_tools/repo_map/repos_to_setup_map.cpp
index d65386a3..19dc7538 100644
--- a/src/other_tools/repo_map/repos_to_setup_map.cpp
+++ b/src/other_tools/repo_map/repos_to_setup_map.cpp
@@ -91,8 +91,15 @@ void GitCheckout(ExpressionPtr const& repo_desc,
? repo_desc_subdir->String()
: "")
.lexically_normal();
- auto repo_desc_ignore_special =
- repo_desc->Get("ignore_special", Expression::none_t{});
+ // check "special" pragma
+ auto repo_desc_pragma = repo_desc->At("pragma");
+ auto pragma_special = repo_desc_pragma
+ ? repo_desc_pragma->get()->At("special")
+ : std::nullopt;
+ auto pragma_special_value =
+ pragma_special and pragma_special->get()->IsString()
+ ? std::make_optional(pragma_special->get()->String())
+ : std::nullopt;
// populate struct
GitRepoInfo git_repo_info = {
.hash = repo_desc_commit->get()->String(),
@@ -100,9 +107,7 @@ void GitCheckout(ExpressionPtr const& repo_desc,
.branch = repo_desc_branch->get()->String(),
.subdir = subdir.empty() ? "." : subdir.string(),
.origin = repo_name,
- .ignore_special = repo_desc_ignore_special->IsBool()
- ? repo_desc_ignore_special->Bool()
- : false};
+ .ignore_special = pragma_special_value == "ignore"};
// get the WS root as git tree
commit_git_map->ConsumeAfterKeysReady(
ts,
@@ -174,8 +179,15 @@ void ArchiveCheckout(ExpressionPtr const& repo_desc,
auto repo_desc_distfile = repo_desc->Get("distfile", Expression::none_t{});
auto repo_desc_sha256 = repo_desc->Get("sha256", Expression::none_t{});
auto repo_desc_sha512 = repo_desc->Get("sha512", Expression::none_t{});
- auto repo_desc_ignore_special =
- repo_desc->Get("ignore_special", Expression::none_t{});
+ // check "special" pragma
+ auto repo_desc_pragma = repo_desc->At("pragma");
+ auto pragma_special = repo_desc_pragma
+ ? repo_desc_pragma->get()->At("special")
+ : std::nullopt;
+ auto pragma_special_value =
+ pragma_special and pragma_special->get()->IsString()
+ ? std::make_optional(pragma_special->get()->String())
+ : std::nullopt;
// populate struct
ArchiveRepoInfo archive_repo_info = {
.archive =
@@ -194,9 +206,7 @@ void ArchiveCheckout(ExpressionPtr const& repo_desc,
.origin_from_distdir = false},
.repo_type = repo_type,
.subdir = subdir.empty() ? "." : subdir.string(),
- .ignore_special = repo_desc_ignore_special->IsBool()
- ? repo_desc_ignore_special->Bool()
- : false};
+ .ignore_special = pragma_special_value == "ignore"};
// get the WS root as git tree
content_git_map->ConsumeAfterKeysReady(
ts,
@@ -250,20 +260,23 @@ void FileCheckout(ExpressionPtr const& repo_desc,
// get absolute path
auto fpath = ToNormalPath(
std::filesystem::absolute(repo_desc_path->get()->String()));
- // get ignore-special entry
- auto repo_desc_ignore_special =
- repo_desc->Get("ignore_special", Expression::none_t{});
- bool ignore_special = repo_desc_ignore_special->IsBool()
- ? repo_desc_ignore_special->Bool()
- : false;
- // check to_git pragma
+ // check "special" pragma
auto repo_desc_pragma = repo_desc->At("pragma");
+ auto pragma_special = repo_desc_pragma
+ ? repo_desc_pragma->get()->At("special")
+ : std::nullopt;
+ auto pragma_special_value =
+ pragma_special and pragma_special->get()->IsString()
+ ? std::make_optional(pragma_special->get()->String())
+ : std::nullopt;
+ // check "to_git" pragma
auto pragma_to_git =
repo_desc_pragma ? repo_desc_pragma->get()->At("to_git") : std::nullopt;
if (pragma_to_git and pragma_to_git->get()->IsBool() and
pragma_to_git->get()->Bool()) {
// get the WS root as git tree
- FpathInfo fpath_info = {fpath, ignore_special};
+ FpathInfo fpath_info = {
+ .fpath = fpath, .ignore_special = pragma_special_value == "ignore"};
fpath_git_map->ConsumeAfterKeysReady(
ts,
{std::move(fpath_info)},
@@ -287,9 +300,11 @@ void FileCheckout(ExpressionPtr const& repo_desc,
else {
// get the WS root as filesystem location
nlohmann::json cfg({});
- cfg["workspace_root"] = nlohmann::json::array(
- {ignore_special ? FileRoot::kFileIgnoreSpecialMarker : "file",
- fpath.string()}); // explicit array
+ cfg["workspace_root"] =
+ nlohmann::json::array({pragma_special_value == "ignore"
+ ? FileRoot::kFileIgnoreSpecialMarker
+ : "file",
+ fpath.string()}); // explicit array
SetReposTakeOver(&cfg, repos, repo_name);
(*setter)(std::move(cfg));
// report local path
@@ -321,12 +336,6 @@ void DistdirCheckout(ExpressionPtr const& repo_desc,
/*fatal=*/true);
return;
}
- // get ignore-special entry
- auto repo_desc_ignore_special =
- repo_desc->Get("ignore_special", Expression::none_t{});
- bool ignore_special = repo_desc_ignore_special->IsBool()
- ? repo_desc_ignore_special->Bool()
- : false;
// map of distfile to content
auto distdir_content =
std::make_shared<std::unordered_map<std::string, std::string>>();
@@ -465,8 +474,7 @@ void DistdirCheckout(ExpressionPtr const& repo_desc,
DistdirInfo distdir_info = {.content_id = distdir_content_id,
.content_list = distdir_content,
.repos_to_fetch = dist_repos_to_fetch,
- .origin = repo_name,
- .ignore_special = ignore_special};
+ .origin = repo_name};
distdir_git_map->ConsumeAfterKeysReady(
ts,
{std::move(distdir_info)},
@@ -558,17 +566,21 @@ void GitTreeCheckout(ExpressionPtr const& repo_desc,
}
}
}
- // get ignore-special entry
- auto repo_desc_ignore_special =
- repo_desc->Get("ignore_special", Expression::none_t{});
- bool ignore_special = repo_desc_ignore_special->IsBool()
- ? repo_desc_ignore_special->Bool()
- : false;
+ // check "special" pragma
+ auto repo_desc_pragma = repo_desc->At("pragma");
+ auto pragma_special = repo_desc_pragma
+ ? repo_desc_pragma->get()->At("special")
+ : std::nullopt;
+ auto pragma_special_value =
+ pragma_special and pragma_special->get()->IsString()
+ ? std::make_optional(pragma_special->get()->String())
+ : std::nullopt;
// populate struct
- TreeIdInfo tree_id_info = {.hash = repo_desc_hash->get()->String(),
- .env_vars = std::move(env),
- .command = std::move(cmd),
- .ignore_special = ignore_special};
+ TreeIdInfo tree_id_info = {
+ .hash = repo_desc_hash->get()->String(),
+ .env_vars = std::move(env),
+ .command = std::move(cmd),
+ .ignore_special = pragma_special_value == "ignore"};
// get the WS root as git tree
tree_id_git_map->ConsumeAfterKeysReady(
ts,
diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS
index d325daa4..56342137 100644
--- a/src/other_tools/root_maps/TARGETS
+++ b/src/other_tools/root_maps/TARGETS
@@ -7,7 +7,6 @@
[ ["@", "json", "", "json"]
, ["src/other_tools/ops_maps", "import_to_git_map"]
, ["src/other_tools/ops_maps", "content_cas_map"]
- , ["src/utils/cpp", "hash_combine"]
]
, "stage": ["src", "other_tools", "root_maps"]
, "private-deps":
diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp
index 13a161aa..a0971478 100644
--- a/src/other_tools/root_maps/distdir_git_map.cpp
+++ b/src/other_tools/root_maps/distdir_git_map.cpp
@@ -90,10 +90,8 @@ auto CreateDistdirGitMap(
critical_git_op_map->ConsumeAfterKeysReady(
ts,
{std::move(op_key)},
- [distdir_tree_id = *distdir_tree_id,
- ignore_special = key.ignore_special,
- setter,
- logger](auto const& values) {
+ [distdir_tree_id = *distdir_tree_id, setter, logger](
+ auto const& values) {
GitOpValue op_result = *values[0];
// check flag
if (not op_result.result) {
@@ -103,14 +101,12 @@ auto CreateDistdirGitMap(
}
// subdir is ".", so no need to deal with the Git cache
// set the workspace root
- (*setter)(std::pair(
- nlohmann::json::array(
- {ignore_special
- ? FileRoot::kGitTreeIgnoreSpecialMarker
- : FileRoot::kGitTreeMarker,
- distdir_tree_id,
- StorageConfig::GitRoot().string()}),
- true));
+ (*setter)(
+ std::pair(nlohmann::json::array(
+ {FileRoot::kGitTreeMarker,
+ distdir_tree_id,
+ StorageConfig::GitRoot().string()}),
+ true));
},
[logger, target_path = StorageConfig::GitRoot()](
auto const& msg, bool fatal) {
@@ -130,7 +126,6 @@ auto CreateDistdirGitMap(
[distdir_tree_id_file,
content_id = key.content_id,
content_list = key.content_list,
- ignore_special = key.ignore_special,
import_to_git_map,
ts,
setter,
@@ -161,7 +156,6 @@ auto CreateDistdirGitMap(
{std::move(c_info)},
[tmp_dir, // keep tmp_dir alive
distdir_tree_id_file,
- ignore_special,
setter,
logger](auto const& values) {
// check for errors
@@ -185,9 +179,7 @@ auto CreateDistdirGitMap(
// set the workspace root
(*setter)(std::pair(
nlohmann::json::array(
- {ignore_special
- ? FileRoot::kGitTreeIgnoreSpecialMarker
- : FileRoot::kGitTreeMarker,
+ {FileRoot::kGitTreeMarker,
distdir_tree_id,
StorageConfig::GitRoot().string()}),
false));
diff --git a/src/other_tools/root_maps/distdir_git_map.hpp b/src/other_tools/root_maps/distdir_git_map.hpp
index 7ede3b95..c440253b 100644
--- a/src/other_tools/root_maps/distdir_git_map.hpp
+++ b/src/other_tools/root_maps/distdir_git_map.hpp
@@ -20,7 +20,6 @@
#include "nlohmann/json.hpp"
#include "src/other_tools/ops_maps/content_cas_map.hpp"
#include "src/other_tools/ops_maps/import_to_git_map.hpp"
-#include "src/utils/cpp/hash_combine.hpp"
struct DistdirInfo {
std::string content_id; /* key */
@@ -28,13 +27,10 @@ struct DistdirInfo {
std::shared_ptr<std::vector<ArchiveContent>> repos_to_fetch;
// name of repository for which work is done; used in progress reporting
std::string origin;
- // create root that ignores symlinks
- bool ignore_special; /* key */
[[nodiscard]] auto operator==(const DistdirInfo& other) const noexcept
-> bool {
- return content_id == other.content_id and
- ignore_special == other.ignore_special;
+ return content_id == other.content_id;
}
};
@@ -55,10 +51,7 @@ template <>
struct hash<DistdirInfo> {
[[nodiscard]] auto operator()(const DistdirInfo& dd) const noexcept
-> std::size_t {
- size_t seed{};
- hash_combine<std::string>(&seed, dd.content_id);
- hash_combine<bool>(&seed, dd.ignore_special);
- return seed;
+ return std::hash<std::string>{}(dd.content_id);
}
};
} // namespace std
diff --git a/test/end-to-end/just-mr/install-roots.sh b/test/end-to-end/just-mr/install-roots.sh
index 368e505a..aab0c90b 100644
--- a/test/end-to-end/just-mr/install-roots.sh
+++ b/test/end-to-end/just-mr/install-roots.sh
@@ -54,10 +54,10 @@ cat > repos.json <<EOF
, "foo_ignore_special":
{ "repository":
{ "type": "archive"
- , "ignore_special": true
, "content": "${foocontent}"
, "fetch": "http://non-existent.example.org/foo-1.2.3.tar"
, "subdir": "foo"
+ , "pragma": {"special": "ignore"}
}
}
, "":