summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildtool/file_system/TARGETS1
-rw-r--r--src/buildtool/file_system/git_repo.cpp13
-rw-r--r--src/buildtool/file_system/git_repo.hpp5
-rw-r--r--src/buildtool/serve_api/serve_service/source_tree.cpp10
-rw-r--r--src/other_tools/git_operations/TARGETS1
-rw-r--r--src/other_tools/git_operations/git_repo_remote.cpp27
-rw-r--r--src/other_tools/git_operations/git_repo_remote.hpp16
-rw-r--r--src/other_tools/ops_maps/TARGETS1
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.cpp32
-rw-r--r--src/other_tools/ops_maps/git_update_map.cpp12
-rw-r--r--src/other_tools/ops_maps/import_to_git_map.cpp12
-rw-r--r--src/other_tools/root_maps/commit_git_map.cpp21
-rw-r--r--test/buildtool/file_system/git_repo.test.cpp21
-rw-r--r--test/other_tools/git_operations/git_repo_remote.test.cpp63
14 files changed, 69 insertions, 166 deletions
diff --git a/src/buildtool/file_system/TARGETS b/src/buildtool/file_system/TARGETS
index b368e5b4..427e7628 100644
--- a/src/buildtool/file_system/TARGETS
+++ b/src/buildtool/file_system/TARGETS
@@ -108,6 +108,7 @@
, ["src/utils/cpp", "path"]
, ["src/utils/cpp", "hex_string"]
, ["src/utils/cpp", "gsl"]
+ , ["src/utils/cpp", "tmp_dir"]
, ["src/buildtool/file_system", "file_system_manager"]
, ["src/buildtool/common", "common"]
]
diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp
index 72f85f6a..2022d0b1 100644
--- a/src/buildtool/file_system/git_repo.cpp
+++ b/src/buildtool/file_system/git_repo.cpp
@@ -23,6 +23,7 @@
#include "src/utils/cpp/gsl.hpp"
#include "src/utils/cpp/hex_string.hpp"
#include "src/utils/cpp/path.hpp"
+#include "src/utils/cpp/tmp_dir.hpp"
extern "C" {
#include <git2.h>
@@ -1541,8 +1542,7 @@ auto GitRepo::GetObjectByPathFromTree(std::string const& tree_id,
#endif // BOOTSTRAP_BUILD_TOOL
}
-auto GitRepo::LocalFetchViaTmpRepo(std::filesystem::path const& tmp_dir,
- std::string const& repo_path,
+auto GitRepo::LocalFetchViaTmpRepo(std::string const& repo_path,
std::optional<std::string> const& branch,
anon_logger_ptr const& logger) noexcept
-> bool {
@@ -1555,10 +1555,17 @@ auto GitRepo::LocalFetchViaTmpRepo(std::filesystem::path const& tmp_dir,
Logger::Log(LogLevel::Debug,
"Branch local fetch called on a real repository");
}
+ auto tmp_dir = TmpDir::Create("local_fetch");
+ if (not tmp_dir) {
+ (*logger)("Failed to create temp dir for Git repository",
+ /*fatal=*/true);
+ return false;
+ }
+ auto const& tmp_path = tmp_dir->GetPath();
// create the temporary real repository
// it can be bare, as the refspecs for this fetch will be given
// explicitly.
- auto tmp_repo = GitRepo::InitAndOpen(tmp_dir, /*is_bare=*/true);
+ auto tmp_repo = GitRepo::InitAndOpen(tmp_path, /*is_bare=*/true);
if (tmp_repo == std::nullopt) {
return false;
}
diff --git a/src/buildtool/file_system/git_repo.hpp b/src/buildtool/file_system/git_repo.hpp
index 09e65402..7d0428d0 100644
--- a/src/buildtool/file_system/git_repo.hpp
+++ b/src/buildtool/file_system/git_repo.hpp
@@ -272,13 +272,10 @@ class GitRepo {
/// \brief Fetch from given local repository via a temporary location. Uses
/// tmp dir to fetch asynchronously using libgit2.
- /// Caller needs to make sure the temporary directory exists and that the
- /// given path is thread- and process-safe!
/// Uses either a given branch, or fetches all (with base refspecs).
/// Returns a success flag.
/// It guarantees the logger is called exactly once with fatal if failure.
[[nodiscard]] auto LocalFetchViaTmpRepo(
- std::filesystem::path const& tmp_dir,
std::string const& repo_path,
std::optional<std::string> const& branch,
anon_logger_ptr const& logger) noexcept -> bool;
@@ -344,4 +341,4 @@ class GitRepo {
std::vector<std::string> const& string_list) noexcept;
};
-#endif // INCLUDED_SRC_BUILDTOOL_FILE_SYSTEM_GIT_REPO_HPP \ No newline at end of file
+#endif // INCLUDED_SRC_BUILDTOOL_FILE_SYSTEM_GIT_REPO_HPP
diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp
index cef433a0..4941f786 100644
--- a/src/buildtool/serve_api/serve_service/source_tree.cpp
+++ b/src/buildtool/serve_api/serve_service/source_tree.cpp
@@ -477,13 +477,6 @@ auto SourceTreeService::CommonImportToGit(
if (not commit_hash) {
return result_t(std::in_place_index<0>, err);
}
- // create a tmp directory for the fetch to Git CAS
- auto tmp_dir = StorageUtils::CreateTypedTmpDir("import-to-git");
- if (not tmp_dir) {
- return result_t(
- std::in_place_index<0>,
- std::string("Failed to create tmp path for git import"));
- }
// open the Git CAS repo
auto just_git_cas = GitCAS::Open(StorageConfig::GitRoot());
if (not just_git_cas) {
@@ -509,8 +502,7 @@ auto SourceTreeService::CommonImportToGit(
});
// fetch the new commit into the Git CAS via tmp directory; the call is
// thread-safe, so it needs no guarding
- if (not just_git_repo->LocalFetchViaTmpRepo(tmp_dir->GetPath(),
- root_path.string(),
+ if (not just_git_repo->LocalFetchViaTmpRepo(root_path.string(),
/*branch=*/std::nullopt,
wrapped_logger)) {
return result_t(std::in_place_index<0>, err);
diff --git a/src/other_tools/git_operations/TARGETS b/src/other_tools/git_operations/TARGETS
index dba6fc18..1cd49035 100644
--- a/src/other_tools/git_operations/TARGETS
+++ b/src/other_tools/git_operations/TARGETS
@@ -36,6 +36,7 @@
, ["@", "json", "", "json"]
, ["src/buildtool/system", "system_command"]
, "git_config_settings"
+ , ["src/utils/cpp", "tmp_dir"]
]
}
, "git_config_settings":
diff --git a/src/other_tools/git_operations/git_repo_remote.cpp b/src/other_tools/git_operations/git_repo_remote.cpp
index 2a434928..f3964e74 100644
--- a/src/other_tools/git_operations/git_repo_remote.cpp
+++ b/src/other_tools/git_operations/git_repo_remote.cpp
@@ -20,6 +20,7 @@
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/system/system_command.hpp"
#include "src/other_tools/git_operations/git_config_settings.hpp"
+#include "src/utils/cpp/tmp_dir.hpp"
extern "C" {
#include <git2.h>
@@ -392,7 +393,6 @@ auto GitRepoRemote::FetchFromRemote(std::shared_ptr<git_config> cfg,
}
auto GitRepoRemote::UpdateCommitViaTmpRepo(
- std::filesystem::path const& tmp_dir,
std::string const& repo_url,
std::string const& branch,
std::vector<std::string> const& inherit_env,
@@ -401,6 +401,13 @@ auto GitRepoRemote::UpdateCommitViaTmpRepo(
anon_logger_ptr const& logger) const noexcept
-> std::optional<std::string> {
try {
+ auto tmp_dir = TmpDir::Create("update");
+ if (not tmp_dir) {
+ (*logger)("Failed to create temp dir for running 'git ls-remote'",
+ /*fatal=*/true);
+ return std::nullopt;
+ }
+ auto const& tmp_path = tmp_dir->GetPath();
// check for internally supported protocols
if (IsSupported(repo_url)) {
// preferably with a "fake" repository!
@@ -410,7 +417,7 @@ auto GitRepoRemote::UpdateCommitViaTmpRepo(
}
// create the temporary real repository
auto tmp_repo =
- GitRepoRemote::InitAndOpen(tmp_dir, /*is_bare=*/true);
+ GitRepoRemote::InitAndOpen(tmp_path / "git", /*is_bare=*/true);
if (tmp_repo == std::nullopt) {
return std::nullopt;
}
@@ -456,7 +463,7 @@ auto GitRepoRemote::UpdateCommitViaTmpRepo(
system.Execute(cmdline,
env,
GetGitPath(), // which path is not actually relevant
- tmp_dir);
+ tmp_path);
if (not command_output) {
(*logger)(fmt::format("exec() on command failed."),
@@ -522,8 +529,7 @@ auto GitRepoRemote::UpdateCommitViaTmpRepo(
}
}
-auto GitRepoRemote::FetchViaTmpRepo(std::filesystem::path const& tmp_dir,
- std::string const& repo_url,
+auto GitRepoRemote::FetchViaTmpRepo(std::string const& repo_url,
std::optional<std::string> const& branch,
std::vector<std::string> const& inherit_env,
std::string const& git_bin,
@@ -531,6 +537,13 @@ auto GitRepoRemote::FetchViaTmpRepo(std::filesystem::path const& tmp_dir,
anon_logger_ptr const& logger) noexcept
-> bool {
try {
+ auto tmp_dir = TmpDir::Create("fetch");
+ if (not tmp_dir) {
+ (*logger)("Failed to create temp dir for running 'git fetch'",
+ /*fatal=*/true);
+ return false;
+ }
+ auto const& tmp_path = tmp_dir->GetPath();
// check for internally supported protocols
if (IsSupported(repo_url)) {
// preferably with a "fake" repository!
@@ -542,7 +555,7 @@ auto GitRepoRemote::FetchViaTmpRepo(std::filesystem::path const& tmp_dir,
// it can be bare, as the refspecs for this fetch will be given
// explicitly.
auto tmp_repo =
- GitRepoRemote::InitAndOpen(tmp_dir, /*is_bare=*/true);
+ GitRepoRemote::InitAndOpen(tmp_path / "git", /*is_bare=*/true);
if (tmp_repo == std::nullopt) {
return false;
}
@@ -606,7 +619,7 @@ auto GitRepoRemote::FetchViaTmpRepo(std::filesystem::path const& tmp_dir,
// run command
SystemCommand system{repo_url};
auto const command_output =
- system.Execute(cmdline, env, GetGitPath(), tmp_dir);
+ system.Execute(cmdline, env, GetGitPath(), tmp_path);
if (not command_output) {
(*logger)(fmt::format("exec() on command failed."),
diff --git a/src/other_tools/git_operations/git_repo_remote.hpp b/src/other_tools/git_operations/git_repo_remote.hpp
index 614e7822..c59fb48e 100644
--- a/src/other_tools/git_operations/git_repo_remote.hpp
+++ b/src/other_tools/git_operations/git_repo_remote.hpp
@@ -82,15 +82,11 @@ class GitRepoRemote : public GitRepo {
/// \brief Get commit from given branch on the remote. If URL is SSH, shells
/// out to system git to perform an ls-remote call, ensuring correct
/// handling of the remote connection settings (in particular proxy and
- /// SSH). A temporary directory is needed to pipe the stdout and stderr to.
- /// If URL is non-SSH, uses tmp dir to connect to remote and retrieve the
- /// commit of a branch asynchronously using libgit2.
- /// Caller needs to make sure the temporary directory exists and that the
- /// given path is thread- and process-safe!
+ /// SSH). For non-SSH URLs, the branch commit is retrieved asynchronously
+ /// using libgit2.
/// Returns the commit hash, as a string, or nullopt if failure.
/// It guarantees the logger is called exactly once with fatal if failure.
[[nodiscard]] auto UpdateCommitViaTmpRepo(
- std::filesystem::path const& tmp_dir,
std::string const& repo_url,
std::string const& branch,
std::vector<std::string> const& inherit_env,
@@ -101,16 +97,12 @@ class GitRepoRemote : public GitRepo {
/// \brief Fetch from a remote. If URL is SSH, shells out to system git to
/// retrieve packs in a safe manner, with the only side-effect being that
- /// there can be some redundancy in the fetched packs. The tmp dir is used
- /// to pipe the stdout and stderr to.
- /// If URL is non-SSH, uses tmp dir to fetch asynchronously using libgit2.
- /// Caller needs to make sure the temporary directory exists and that the
- /// given path is thread- and process-safe!
+ /// there can be some redundancy in the fetched packs.
+ /// For non-SSH URLs an asynchronous fetch is performed using libgit2.
/// Uses either a given branch, or fetches all (with base refspecs).
/// Returns a success flag.
/// It guarantees the logger is called exactly once with fatal if failure.
[[nodiscard]] auto FetchViaTmpRepo(
- std::filesystem::path const& tmp_dir,
std::string const& repo_url,
std::optional<std::string> const& branch,
std::vector<std::string> const& inherit_env,
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS
index 41f73000..4a15849f 100644
--- a/src/other_tools/ops_maps/TARGETS
+++ b/src/other_tools/ops_maps/TARGETS
@@ -48,7 +48,6 @@
[ ["@", "fmt", "", "fmt"]
, ["src/buildtool/execution_api/local", "config"]
, ["src/buildtool/storage", "fs_utils"]
- , ["src/utils/cpp", "tmp_dir"]
, ["src/other_tools/just_mr/progress_reporting", "statistics"]
, ["src/other_tools/just_mr/progress_reporting", "progress"]
]
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
index 38e25606..423808cc 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
@@ -419,7 +419,6 @@ auto CreateGitTreeFetchMap(
fatal);
});
if (not just_git_repo->FetchViaTmpRepo(
- tmp_dir->GetPath(),
target_path.string(),
std::nullopt,
key.inherit_env,
@@ -454,12 +453,8 @@ auto CreateGitTreeFetchMap(
critical_git_op_map->ConsumeAfterKeysReady(
ts,
{std::move(op_key)},
- [tmp_dir, // keep tmp_dir alive
- remote_api,
- backup_to_remote,
- key,
- setter,
- logger](auto const& values) {
+ [remote_api, backup_to_remote, key, setter, logger](
+ auto const& values) {
GitOpValue op_result = *values[0];
// check flag
if (not op_result.result) {
@@ -477,28 +472,21 @@ auto CreateGitTreeFetchMap(
// success
(*setter)(false /*no cache hit*/);
},
- [logger,
- commit = *op_result.result,
- target_path = tmp_dir->GetPath()](auto const& msg,
- bool fatal) {
+ [logger, commit = *op_result.result](
+ auto const& msg, bool fatal) {
(*logger)(
fmt::format("While running critical Git op "
- "KEEP_TAG for commit {} in "
- "target {}:\n{}",
+ "KEEP_TAG for commit {}:\n{}",
commit,
- target_path.string(),
msg),
fatal);
});
},
- [logger, target_path = tmp_dir->GetPath()](auto const& msg,
- bool fatal) {
- (*logger)(
- fmt::format("While running critical Git op "
- "INITIAL_COMMIT for target {}:\n{}",
- target_path.string(),
- msg),
- fatal);
+ [logger](auto const& msg, bool fatal) {
+ (*logger)(fmt::format("While running critical Git op "
+ "INITIAL_COMMIT:\n{}",
+ msg),
+ fatal);
});
},
[logger, target_path = StorageConfig::GitRoot()](auto const& msg,
diff --git a/src/other_tools/ops_maps/git_update_map.cpp b/src/other_tools/ops_maps/git_update_map.cpp
index 0ce9de49..9886b84b 100644
--- a/src/other_tools/ops_maps/git_update_map.cpp
+++ b/src/other_tools/ops_maps/git_update_map.cpp
@@ -19,7 +19,6 @@
#include "src/buildtool/storage/fs_utils.hpp"
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
-#include "src/utils/cpp/tmp_dir.hpp"
auto CreateGitUpdateMap(GitCASPtr const& git_cas,
std::string const& git_bin,
@@ -39,14 +38,6 @@ auto CreateGitUpdateMap(GitCASPtr const& git_cas,
/*fatal=*/true);
return;
}
- auto tmp_dir = StorageUtils::CreateTypedTmpDir("update");
- if (not tmp_dir) {
- (*logger)(fmt::format("Failed to create commit update tmp dir for "
- "remote {}",
- key.repo),
- /*fatal=*/true);
- return;
- }
// setup wrapped logger
auto wrapped_logger = std::make_shared<AsyncMapConsumerLogger>(
[logger](auto const& msg, bool fatal) {
@@ -57,8 +48,7 @@ auto CreateGitUpdateMap(GitCASPtr const& git_cas,
// update commit
auto id = fmt::format("{}:{}", key.repo, key.branch);
JustMRProgress::Instance().TaskTracker().Start(id);
- auto new_commit = git_repo->UpdateCommitViaTmpRepo(tmp_dir->GetPath(),
- key.repo,
+ auto new_commit = git_repo->UpdateCommitViaTmpRepo(key.repo,
key.branch,
key.inherit_env,
git_bin,
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 4051cb01..991fc369 100644
--- a/src/other_tools/ops_maps/import_to_git_map.cpp
+++ b/src/other_tools/ops_maps/import_to_git_map.cpp
@@ -167,17 +167,6 @@ auto CreateImportToGitMap(
/*fatal=*/true);
return;
}
- // create tmp directory
- auto tmp_dir =
- StorageUtils::CreateTypedTmpDir("import-to-git");
- if (not tmp_dir) {
- (*logger)(
- fmt::format("Could not create unique path "
- "for target {}",
- target_path.string()),
- /*fatal=*/true);
- return;
- }
auto wrapped_logger =
std::make_shared<AsyncMapConsumerLogger>(
[logger, target_path](auto const& msg,
@@ -190,7 +179,6 @@ auto CreateImportToGitMap(
fatal);
});
if (not just_git_repo->FetchViaTmpRepo(
- tmp_dir->GetPath(),
target_path.string(),
std::nullopt,
std::vector<std::string>{} /* XXX */,
diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp
index d97f33be..a64ccc49 100644
--- a/src/other_tools/root_maps/commit_git_map.cpp
+++ b/src/other_tools/root_maps/commit_git_map.cpp
@@ -29,7 +29,6 @@
#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
#include "src/other_tools/root_maps/root_utils.hpp"
#include "src/other_tools/utils/curl_url_handle.hpp"
-#include "src/utils/cpp/tmp_dir.hpp"
namespace {
@@ -224,13 +223,6 @@ void NetworkFetchAndSetPresentRoot(
return;
}
- // default to fetching from network
- auto tmp_dir = StorageUtils::CreateTypedTmpDir("fetch");
- if (not tmp_dir) {
- (*logger)("Failed to create fetch tmp directory!",
- /*fatal=*/true);
- return;
- }
// store failed attempts for subsequent logging
bool fetched{false};
std::string err_messages{};
@@ -251,8 +243,7 @@ void NetworkFetchAndSetPresentRoot(
mirror,
msg);
});
- if (git_repo->FetchViaTmpRepo(tmp_dir->GetPath(),
- mirror,
+ if (git_repo->FetchViaTmpRepo(mirror,
repo_info.branch,
repo_info.inherit_env,
git_bin,
@@ -284,8 +275,7 @@ void NetworkFetchAndSetPresentRoot(
*preferred_url,
msg);
});
- if (git_repo->FetchViaTmpRepo(tmp_dir->GetPath(),
- *preferred_url,
+ if (git_repo->FetchViaTmpRepo(*preferred_url,
repo_info.branch,
repo_info.inherit_env,
git_bin,
@@ -316,8 +306,7 @@ void NetworkFetchAndSetPresentRoot(
fetch_repo,
msg);
});
- if (git_repo->FetchViaTmpRepo(tmp_dir->GetPath(),
- fetch_repo,
+ if (git_repo->FetchViaTmpRepo(fetch_repo,
repo_info.branch,
repo_info.inherit_env,
git_bin,
@@ -352,7 +341,6 @@ void NetworkFetchAndSetPresentRoot(
msg);
});
if (git_repo->FetchViaTmpRepo(
- tmp_dir->GetPath(),
*preferred_mirror,
repo_info.branch,
repo_info.inherit_env,
@@ -386,8 +374,7 @@ void NetworkFetchAndSetPresentRoot(
mirror,
msg);
});
- if (git_repo->FetchViaTmpRepo(tmp_dir->GetPath(),
- mirror,
+ if (git_repo->FetchViaTmpRepo(mirror,
repo_info.branch,
repo_info.inherit_env,
git_bin,
diff --git a/test/buildtool/file_system/git_repo.test.cpp b/test/buildtool/file_system/git_repo.test.cpp
index e9992a97..26ebd8ce 100644
--- a/test/buildtool/file_system/git_repo.test.cpp
+++ b/test/buildtool/file_system/git_repo.test.cpp
@@ -405,12 +405,9 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo]") {
CHECK_FALSE(
*repo_fetch_all->CheckCommitExists(kRootCommit, logger));
- // create tmp dir to use for fetch
- auto tmp_path_fetch_all = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(tmp_path_fetch_all));
// fetch all with base refspecs
REQUIRE(repo_fetch_all->LocalFetchViaTmpRepo(
- tmp_path_fetch_all, *repo_path, std::nullopt, logger));
+ *repo_path, std::nullopt, logger));
// check commit is there after fetch
CHECK(*repo_fetch_all->CheckCommitExists(kRootCommit, logger));
@@ -427,12 +424,9 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo]") {
CHECK_FALSE(
*repo_fetch_branch->CheckCommitExists(kRootCommit, logger));
- // create tmp dir to use for fetch
- auto tmp_path_fetch_branch = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(tmp_path_fetch_branch));
// fetch branch
REQUIRE(repo_fetch_branch->LocalFetchViaTmpRepo(
- tmp_path_fetch_branch, *repo_path, "master", logger));
+ *repo_path, "master", logger));
// check commit is there after fetch
CHECK(*repo_fetch_branch->CheckCommitExists(kRootCommit, logger));
@@ -532,18 +526,9 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo]") {
auto remote_repo = GitRepo::Open(remote_cas);
REQUIRE(remote_repo);
REQUIRE(remote_repo->IsRepoFake());
- // set up tmp dir
- // create tmp dir to use for fetch
- auto tmp_path_fetch_branch =
- TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(
- tmp_path_fetch_branch));
// fetch all
REQUIRE(remote_repo->LocalFetchViaTmpRepo(
- tmp_path_fetch_branch,
- *remote_repo_path,
- std::nullopt,
- logger));
+ *remote_repo_path, std::nullopt, logger));
} break;
}
},
diff --git a/test/other_tools/git_operations/git_repo_remote.test.cpp b/test/other_tools/git_operations/git_repo_remote.test.cpp
index 03df8553..0330e9be 100644
--- a/test/other_tools/git_operations/git_repo_remote.test.cpp
+++ b/test/other_tools/git_operations/git_repo_remote.test.cpp
@@ -240,17 +240,9 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
CHECK_FALSE(
*repo_fetch_all->CheckCommitExists(kRootCommit, logger));
- // create tmp dir to use for fetch
- auto tmp_path_fetch_all = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(tmp_path_fetch_all));
// fetch all with base refspecs
- REQUIRE(repo_fetch_all->FetchViaTmpRepo(tmp_path_fetch_all,
- *repo_path,
- std::nullopt,
- {},
- "git",
- {},
- logger));
+ REQUIRE(repo_fetch_all->FetchViaTmpRepo(
+ *repo_path, std::nullopt, {}, "git", {}, logger));
// check commit is there after fetch
CHECK(*repo_fetch_all->CheckCommitExists(kRootCommit, logger));
@@ -267,19 +259,9 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
CHECK_FALSE(
*repo_fetch_wRefspec->CheckCommitExists(kRootCommit, logger));
- // create tmp dir to use for fetch
- auto tmp_path_fetch_wRefspec = TestUtils::GetRepoPath();
- REQUIRE(
- FileSystemManager::CreateDirectory(tmp_path_fetch_wRefspec));
// fetch all
- REQUIRE(
- repo_fetch_wRefspec->FetchViaTmpRepo(tmp_path_fetch_wRefspec,
- *repo_path,
- "master",
- {},
- "git",
- {},
- logger));
+ REQUIRE(repo_fetch_wRefspec->FetchViaTmpRepo(
+ *repo_path, "master", {}, "git", {}, logger));
// check commit is there after fetch
CHECK(*repo_fetch_wRefspec->CheckCommitExists(kRootCommit, logger));
@@ -292,12 +274,9 @@ TEST_CASE("Single-threaded fake repository operations", "[git_repo_remote]") {
GitRepoRemote::InitAndOpen(path_commit_upd, /*is_bare=*/true);
REQUIRE(repo_commit_upd);
- // create tmp dir to use for commits update
- auto tmp_path_commit_upd = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(tmp_path_commit_upd));
// do remote ls
auto fetched_commit = repo_commit_upd->UpdateCommitViaTmpRepo(
- tmp_path_commit_upd, *repo_path, "master", {}, "git", {}, logger);
+ *repo_path, "master", {}, "git", {}, logger);
REQUIRE(fetched_commit);
CHECK(*fetched_commit == kRootCommit);
@@ -356,14 +335,9 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo_remote]") {
// something
} break;
case 1: {
- // create tmp dir to use for fetch
- auto tmp_path_fetch_all = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(
- tmp_path_fetch_all));
// fetch with base refspecs
CHECK(
- target_repo->FetchViaTmpRepo(tmp_path_fetch_all,
- *remote_repo_path,
+ target_repo->FetchViaTmpRepo(*remote_repo_path,
std::nullopt,
{},
"git",
@@ -371,30 +345,19 @@ TEST_CASE("Multi-threaded fake repository operations", "[git_repo_remote]") {
logger));
} break;
case 2: {
- // create tmp dir to use for fetch
- auto tmp_path_fetch_wRefspec =
- TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(
- tmp_path_fetch_wRefspec));
// fetch specific branch
- CHECK(target_repo->FetchViaTmpRepo(
- tmp_path_fetch_wRefspec,
- *remote_repo_path,
- "master",
- {},
- "git",
- {},
- logger));
+ CHECK(
+ target_repo->FetchViaTmpRepo(*remote_repo_path,
+ "master",
+ {},
+ "git",
+ {},
+ logger));
} break;
case 3: {
- // create tmp dir to use for commits update
- auto tmp_path_commit_upd = TestUtils::GetRepoPath();
- REQUIRE(FileSystemManager::CreateDirectory(
- tmp_path_commit_upd));
// do remote ls
auto fetched_commit =
target_repo->UpdateCommitViaTmpRepo(
- tmp_path_commit_upd,
*remote_repo_path,
"master",
{},