summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-03-21 15:45:29 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-03-23 09:50:43 +0100
commite0c38d7083e6c972a432bfff3a9863f251f2170c (patch)
tree1290f8c97f99194089db67f61b23d79ad542b2ab
parent12d0c288ea23e1bd7e0401223ba413bca3d94869 (diff)
downloadjustbuild-e0c38d7083e6c972a432bfff3a9863f251f2170c.tar.gz
just-mr: Update calls to fetch and update operations...
...to ensure the temporary directories exist before they are needed, as expected by those methods. This way, the TmpDir class takes care to also clean up after itself. Also, pass the local launcher to the methods that now shell out.
-rw-r--r--src/other_tools/just_mr/main.cpp10
-rw-r--r--src/other_tools/ops_maps/git_update_map.cpp2
-rw-r--r--src/other_tools/ops_maps/import_to_git_map.cpp20
-rw-r--r--src/other_tools/root_maps/tree_id_git_map.cpp19
4 files changed, 28 insertions, 23 deletions
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index bba90162..9f2a47ce 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -1007,8 +1007,9 @@ void DefaultReachableRepositories(
// Initialize resulting config to be updated
auto mr_config = config->ToJson();
// Create async map
- auto git_update_map =
- CreateGitUpdateMap(git_repo->GetGitCAS(), arguments.common.jobs);
+ auto git_update_map = CreateGitUpdateMap(git_repo->GetGitCAS(),
+ *arguments.common.local_launcher,
+ arguments.common.jobs);
// set up progress observer
JustMRProgress::Instance().SetTotal(repos_to_update.size());
@@ -1116,10 +1117,13 @@ void DefaultReachableRepositories(
arguments.common.ca_info,
arguments.common.jobs);
auto import_to_git_map =
- CreateImportToGitMap(&critical_git_op_map, arguments.common.jobs);
+ CreateImportToGitMap(&critical_git_op_map,
+ *arguments.common.local_launcher,
+ arguments.common.jobs);
auto commit_git_map = CreateCommitGitMap(&critical_git_op_map,
arguments.common.just_mr_paths,
+ *arguments.common.local_launcher,
arguments.common.jobs);
auto content_git_map = CreateContentGitMap(&content_cas_map,
&import_to_git_map,
diff --git a/src/other_tools/ops_maps/git_update_map.cpp b/src/other_tools/ops_maps/git_update_map.cpp
index f096d3a9..d399ff40 100644
--- a/src/other_tools/ops_maps/git_update_map.cpp
+++ b/src/other_tools/ops_maps/git_update_map.cpp
@@ -50,7 +50,7 @@ auto CreateGitUpdateMap(GitCASPtr const& git_cas,
auto wrapped_logger = std::make_shared<AsyncMapConsumerLogger>(
[logger](auto const& msg, bool fatal) {
(*logger)(
- fmt::format("While updating commit via tmp repo:\n{}", msg),
+ fmt::format("While updating commit from remote:\n{}", msg),
fatal);
});
// update commit
diff --git a/src/other_tools/ops_maps/import_to_git_map.cpp b/src/other_tools/ops_maps/import_to_git_map.cpp
index 278e9df1..2a3ddee2 100644
--- a/src/other_tools/ops_maps/import_to_git_map.cpp
+++ b/src/other_tools/ops_maps/import_to_git_map.cpp
@@ -157,9 +157,10 @@ auto CreateImportToGitMap(
/*fatal=*/true);
return;
}
- // define temp repo path
- auto tmp_repo_path = CreateUniquePath(target_path);
- if (not tmp_repo_path) {
+ // create tmp directory
+ auto tmp_dir =
+ JustMR::Utils::CreateTypedTmpDir("import-to-git");
+ if (not tmp_dir) {
(*logger)(
fmt::format("Could not create unique path "
"for target {}",
@@ -178,13 +179,12 @@ auto CreateImportToGitMap(
msg),
fatal);
});
- auto success =
- just_git_repo->FetchViaTmpRepo(*tmp_repo_path,
- target_path.string(),
- std::nullopt,
- launcher,
- wrapped_logger);
- if (not success) {
+ if (not just_git_repo->FetchViaTmpRepo(
+ tmp_dir->GetPath(),
+ target_path.string(),
+ std::nullopt,
+ launcher,
+ wrapped_logger)) {
return;
}
// setup a wrapped_logger
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 7d750b8f..a1f6b25c 100644
--- a/src/other_tools/root_maps/tree_id_git_map.cpp
+++ b/src/other_tools/root_maps/tree_id_git_map.cpp
@@ -270,8 +270,10 @@ auto CreateTreeIdGitMap(
return;
}
// define temp repo path
- auto tmp_repo_path = CreateUniquePath(target_path);
- if (not tmp_repo_path) {
+ auto tmp_dir =
+ JustMR::Utils::CreateTypedTmpDir("git-tree");
+ ;
+ if (not tmp_dir) {
(*logger)(fmt::format("Could not create unique "
"path for target {}",
target_path.string()),
@@ -290,13 +292,12 @@ auto CreateTreeIdGitMap(
msg),
fatal);
});
- auto success = just_git_repo->FetchViaTmpRepo(
- *tmp_repo_path,
- target_path.string(),
- std::nullopt,
- launcher,
- wrapped_logger);
- if (not success) {
+ if (not just_git_repo->FetchViaTmpRepo(
+ tmp_dir->GetPath(),
+ target_path.string(),
+ std::nullopt,
+ launcher,
+ wrapped_logger)) {
return;
}
// setup a wrapped_logger