diff options
-rw-r--r-- | src/other_tools/root_maps/tree_id_git_map.cpp | 11 | ||||
-rw-r--r-- | test/end-to-end/just-mr/absent-roots.sh | 31 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/other_tools/root_maps/tree_id_git_map.cpp b/src/other_tools/root_maps/tree_id_git_map.cpp index ce2fe5e5..752f224d 100644 --- a/src/other_tools/root_maps/tree_id_git_map.cpp +++ b/src/other_tools/root_maps/tree_id_git_map.cpp @@ -96,7 +96,16 @@ auto CreateTreeIdGitMap( auto logger, auto /*unused*/, auto const& key) { - // first, check whether tree exists already in CAS + // if root is absent, no work needs to be done + if (key.absent) { + auto root = nlohmann::json::array( + {key.ignore_special ? FileRoot::kGitTreeIgnoreSpecialMarker + : FileRoot::kGitTreeMarker, + key.hash}); + (*setter)(std::pair(std::move(root), false)); + return; + } + // check whether tree exists already in CAS // ensure Git cache // define Git operation to be done GitOpKey op_key = {.params = diff --git a/test/end-to-end/just-mr/absent-roots.sh b/test/end-to-end/just-mr/absent-roots.sh index 7f3154a6..ad4846e1 100644 --- a/test/end-to-end/just-mr/absent-roots.sh +++ b/test/end-to-end/just-mr/absent-roots.sh @@ -109,4 +109,35 @@ test $(jq -r '.repositories.test.workspace_root | length' "${CONF}") = 2 # Check the tree was correctly set via 'just serve' remote test "$(jq -r '.repositories.test.workspace_root[1]' "${CONF}")" = "${GIT_ROOT_ID}" +# Now check that an absent git tree repository works without running the command +rm -rf "${LBR}" + +cat > repos.json <<EOF +{ "repositories": + { "test": + { "repository": + { "type": "git tree" + , "id": "${GIT_ROOT_ID}" + , "cmd": ["non_existent_script.sh"] + , "pragma": {"absent": true} + } + } + } +} +EOF +echo "Repository configuration:" +cat repos.json + +# Compute the repository configuration +CONF=$("${JUST_MR}" --norc --local-build-root "${LBR}" --remote-serve-address localhost:${PORT} setup) +cat "${CONF}" +echo + +# Check that an absent root was created +test "$(jq -r '.repositories.test.workspace_root[0]' "${CONF}")" = "git tree" +test $(jq -r '.repositories.test.workspace_root | length' "${CONF}") = 2 + +# Check the tree was correctly set via 'just serve' remote +test "$(jq -r '.repositories.test.workspace_root[1]' "${CONF}")" = "${GIT_ROOT_ID}" + echo OK |