summaryrefslogtreecommitdiff
path: root/src/buildtool/computed_roots/evaluate.cpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-01-14 17:59:01 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-01-21 09:58:36 +0100
commitaa8635c6863646f5df78b54832f51db16aac25ba (patch)
tree6dd9d592b463e2968c42c4e0b7b891e2c6013e06 /src/buildtool/computed_roots/evaluate.cpp
parent6fa286a674059f2f4a4dd6033aacb13b2d6d1e40 (diff)
downloadjustbuild-aa8635c6863646f5df78b54832f51db16aac25ba.tar.gz
TreeStructureUtils: export from git
Diffstat (limited to 'src/buildtool/computed_roots/evaluate.cpp')
-rw-r--r--src/buildtool/computed_roots/evaluate.cpp55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/buildtool/computed_roots/evaluate.cpp b/src/buildtool/computed_roots/evaluate.cpp
index 0905c240..ffac5e04 100644
--- a/src/buildtool/computed_roots/evaluate.cpp
+++ b/src/buildtool/computed_roots/evaluate.cpp
@@ -46,7 +46,6 @@
#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/common/api_bundle.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
-#include "src/buildtool/execution_api/git/git_api.hpp"
#include "src/buildtool/execution_api/local/config.hpp"
#include "src/buildtool/execution_api/local/context.hpp"
#include "src/buildtool/execution_api/local/local_api.hpp"
@@ -411,6 +410,7 @@ void ComputeTreeStructureAndFill(
if (not resolved_hash) {
// If the tree is not in the storage, it must be added:
if (not storage.CAS().TreePath(*digest).has_value()) {
+ std::vector<std::filesystem::path> known_repos;
auto const path_to_git_cas = ref_root.GetGitCasRoot();
if (not path_to_git_cas) {
std::invoke(*logger,
@@ -420,45 +420,36 @@ void ComputeTreeStructureAndFill(
true);
return;
}
+ known_repos.push_back(*path_to_git_cas);
+ known_repos.push_back(native_storage_config.GitRoot());
- RepositoryConfig root_config{};
- if (not root_config.SetGitCAS(*path_to_git_cas)) {
- std::invoke(
- *logger,
- fmt::format("Failed to set git cas for {}", key.ToString()),
- true);
+ auto in_cas = TreeStructureUtils::ExportFromGit(
+ *digest, known_repos, native_local_api);
+ if (not in_cas.has_value()) {
+ std::invoke(*logger, std::move(in_cas).error(), /*fatal=*/true);
return;
}
+ }
- GitApi const git_api{&root_config};
- if (not git_api.RetrieveToCas(
- {Artifact::ObjectInfo{*digest, ObjectType::Tree}},
- native_local_api) or
- not storage.CAS().TreePath(*digest).has_value()) {
- std::invoke(*logger,
- fmt::format("Failed to retrieve {} to CAS for {}",
- digest->hash(),
- key.ToString()),
- true);
+ if (storage.CAS().TreePath(*digest).has_value()) {
+ // Compute tree structure and add it to the cache:
+ auto const tree_structure = TreeStructureUtils::Compute(
+ *digest, storage, tree_structure_cache);
+ if (not tree_structure) {
+ std::invoke(*logger, tree_structure.error(), /*fatal=*/true);
return;
}
- }
- // Compute tree structure and add it to the cache:
- auto const tree_structure =
- TreeStructureUtils::Compute(*digest, storage, tree_structure_cache);
- if (not tree_structure) {
- std::invoke(*logger, tree_structure.error(), /*fatal=*/true);
- return;
- }
-
- auto to_git = TreeStructureUtils::ImportToGit(
- *tree_structure, native_local_api, native_storage_config, git_lock);
- if (not to_git.has_value()) {
- std::invoke(*logger, std::move(to_git).error(), /*fatal=*/true);
- return;
+ auto to_git = TreeStructureUtils::ImportToGit(*tree_structure,
+ native_local_api,
+ native_storage_config,
+ git_lock);
+ if (not to_git.has_value()) {
+ std::invoke(*logger, std::move(to_git).error(), /*fatal=*/true);
+ return;
+ }
+ resolved_hash = tree_structure->hash();
}
- resolved_hash = tree_structure->hash();
}
if (not resolved_hash) {