summaryrefslogtreecommitdiff
path: root/src/other_tools/root_maps/distdir_git_map.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-09-08 18:15:01 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-09-13 16:14:43 +0200
commit669d1d8714b258ffd19f1610028374233a143f4b (patch)
treeef3774508075f028637844fac2095a5dc2cbce08 /src/other_tools/root_maps/distdir_git_map.cpp
parentf48e1ebe7f08159004bf9a88d5a9e474ff32dbb1 (diff)
downloadjustbuild-669d1d8714b258ffd19f1610028374233a143f4b.tar.gz
just-mr: Implement 'absent' roots
...via an 'absent' pragma in repository descriptions. For 'git'-type repositories, first interrogates a 'just serve' remote, if given, before reverting to fetching from the network.
Diffstat (limited to 'src/other_tools/root_maps/distdir_git_map.cpp')
-rw-r--r--src/other_tools/root_maps/distdir_git_map.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp
index a0971478..a132cf47 100644
--- a/src/other_tools/root_maps/distdir_git_map.cpp
+++ b/src/other_tools/root_maps/distdir_git_map.cpp
@@ -90,8 +90,10 @@ auto CreateDistdirGitMap(
critical_git_op_map->ConsumeAfterKeysReady(
ts,
{std::move(op_key)},
- [distdir_tree_id = *distdir_tree_id, setter, logger](
- auto const& values) {
+ [distdir_tree_id = *distdir_tree_id,
+ absent = key.absent,
+ setter,
+ logger](auto const& values) {
GitOpValue op_result = *values[0];
// check flag
if (not op_result.result) {
@@ -101,12 +103,12 @@ auto CreateDistdirGitMap(
}
// subdir is ".", so no need to deal with the Git cache
// set the workspace root
- (*setter)(
- std::pair(nlohmann::json::array(
- {FileRoot::kGitTreeMarker,
- distdir_tree_id,
- StorageConfig::GitRoot().string()}),
- true));
+ auto root = nlohmann::json::array(
+ {FileRoot::kGitTreeMarker, distdir_tree_id});
+ if (not absent) {
+ root.emplace_back(StorageConfig::GitRoot().string());
+ }
+ (*setter)(std::pair(std::move(root), true));
},
[logger, target_path = StorageConfig::GitRoot()](
auto const& msg, bool fatal) {
@@ -126,6 +128,7 @@ auto CreateDistdirGitMap(
[distdir_tree_id_file,
content_id = key.content_id,
content_list = key.content_list,
+ absent = key.absent,
import_to_git_map,
ts,
setter,
@@ -156,6 +159,7 @@ auto CreateDistdirGitMap(
{std::move(c_info)},
[tmp_dir, // keep tmp_dir alive
distdir_tree_id_file,
+ absent,
setter,
logger](auto const& values) {
// check for errors
@@ -177,12 +181,13 @@ auto CreateDistdirGitMap(
return;
}
// set the workspace root
- (*setter)(std::pair(
- nlohmann::json::array(
- {FileRoot::kGitTreeMarker,
- distdir_tree_id,
- StorageConfig::GitRoot().string()}),
- false));
+ auto root = nlohmann::json::array(
+ {FileRoot::kGitTreeMarker, distdir_tree_id});
+ if (not absent) {
+ root.emplace_back(
+ StorageConfig::GitRoot().string());
+ }
+ (*setter)(std::pair(std::move(root), false));
},
[logger, target_path = tmp_dir->GetPath()](
auto const& msg, bool fatal) {