From 9d5047bb2b6d1756385fc4fabf2a3d54d9e9ac93 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 15 Jun 2022 14:51:03 +0200 Subject: Repository representation: also use string as name in bindings In this way, we keep the repsitory description more close to a normal multi-repository configuration. The only difference remaining is the absence of repository locations for git-tree roots. --- src/buildtool/common/repository_config.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/buildtool/common/repository_config.cpp') diff --git a/src/buildtool/common/repository_config.cpp b/src/buildtool/common/repository_config.cpp index eb72b1c6..ba45052a 100644 --- a/src/buildtool/common/repository_config.cpp +++ b/src/buildtool/common/repository_config.cpp @@ -83,7 +83,7 @@ auto RepositoryConfig::BuildGraphForRepository(std::string const& repo) const -> std::optional { auto graph = nlohmann::json::object(); int id_counter{}; - std::unordered_map repo_ids{}; + std::unordered_map repo_ids{}; if (AddToGraphAndGetId(&graph, &id_counter, &repo_ids, repo)) { return graph; } @@ -98,8 +98,9 @@ auto RepositoryConfig::BuildGraphForRepository(std::string const& repo) const auto RepositoryConfig::AddToGraphAndGetId( gsl::not_null const& graph, gsl::not_null const& id_counter, - gsl::not_null*> const& repo_ids, - std::string const& repo) const -> std::optional { + gsl::not_null*> const& + repo_ids, + std::string const& repo) const -> std::optional { auto const& unique_repo = DeduplicateRepo(repo); auto repo_it = repo_ids->find(unique_repo); if (repo_it != repo_ids->end()) { @@ -110,7 +111,7 @@ auto RepositoryConfig::AddToGraphAndGetId( auto const* data = Data(unique_repo); if (data != nullptr and data->base_desc) { // Compute the unique id (traversal order) and store it - auto repo_id = (*id_counter)++; + auto repo_id = std::to_string((*id_counter)++); repo_ids->emplace(unique_repo, repo_id); // Compute repository description from content-fixed base @@ -123,11 +124,11 @@ auto RepositoryConfig::AddToGraphAndGetId( if (not global_id) { return std::nullopt; } - repo_desc["bindings"][local_name] = *global_id; + repo_desc["bindings"][local_name] = std::move(*global_id); } // Add repository description to graph with unique id as key - (*graph)[std::to_string(repo_id)] = std::move(repo_desc); + (*graph)[repo_id] = std::move(repo_desc); return repo_id; } return std::nullopt; -- cgit v1.2.3