diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-05-26 14:46:25 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-06-04 14:34:44 +0200 |
commit | 811e9be4cc9604dba3d768639444c0d9f849a3c7 (patch) | |
tree | 15460350b2554be422b76c0cc817a4e5d8a1421e /src/buildtool/tree_structure | |
parent | 8d4f583d63c657397583f778096b8bcb6d96c12f (diff) | |
download | justbuild-811e9be4cc9604dba3d768639444c0d9f849a3c7.tar.gz |
RepositoryConfig: Give access to a persistent storage config...
...whenever it is given access to a Git repository.
The referenced storage config needs to outlive the repository
config instance.
Diffstat (limited to 'src/buildtool/tree_structure')
-rw-r--r-- | src/buildtool/tree_structure/tree_structure_utils.cpp | 6 | ||||
-rw-r--r-- | src/buildtool/tree_structure/tree_structure_utils.hpp | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/buildtool/tree_structure/tree_structure_utils.cpp b/src/buildtool/tree_structure/tree_structure_utils.cpp index f09d627b..758e47fc 100644 --- a/src/buildtool/tree_structure/tree_structure_utils.cpp +++ b/src/buildtool/tree_structure/tree_structure_utils.cpp @@ -208,6 +208,7 @@ auto TreeStructureUtils::ImportToGit( auto TreeStructureUtils::ExportFromGit( ArtifactDigest const& tree, std::vector<std::filesystem::path> const& source_repos, + StorageConfig const& storage_config, IExecutionApi const& target_api) noexcept -> expected<bool, std::string> { if (not tree.IsTree() or not ProtocolTraits::IsNative(tree.GetHashType())) { return unexpected{fmt::format("Not a git tree: {}", tree.hash())}; @@ -231,7 +232,7 @@ auto TreeStructureUtils::ExportFromGit( } RepositoryConfig repo_config{}; - if (not repo_config.SetGitCAS(*repo)) { + if (not repo_config.SetGitCAS(*repo, &storage_config)) { return unexpected{ fmt::format("Failed to set git cas at {}", repo->string())}; } @@ -276,7 +277,8 @@ auto TreeStructureUtils::ComputeStructureLocally( // If the tree is not in the storage, it must be present in git: if (not storage.CAS().TreePath(tree).has_value()) { - auto in_cas = ExportFromGit(tree, known_repositories, local_api); + auto in_cas = + ExportFromGit(tree, known_repositories, storage_config, local_api); if (not in_cas.has_value()) { return unexpected{ fmt::format("While exporting {} from git to CAS:\n{}", diff --git a/src/buildtool/tree_structure/tree_structure_utils.hpp b/src/buildtool/tree_structure/tree_structure_utils.hpp index 7cecf7f8..93615cf0 100644 --- a/src/buildtool/tree_structure/tree_structure_utils.hpp +++ b/src/buildtool/tree_structure/tree_structure_utils.hpp @@ -67,12 +67,14 @@ class TreeStructureUtils final { /// regular GitApi for retrieval from git and doesn't perform rehashing. /// \param tree Tree to export /// \param source_repos Repositories to check + /// \param storage_config Storage to use for lookups /// \param target_api Api to export the tree to /// \return True if target api contains tree after the call, false if none /// of source repositories contain tree, or an error message on failure. [[nodiscard]] static auto ExportFromGit( ArtifactDigest const& tree, std::vector<std::filesystem::path> const& source_repos, + StorageConfig const& storage_config, IExecutionApi const& target_api) noexcept -> expected<bool, std::string>; |