summaryrefslogtreecommitdiff
path: root/src/other_tools/git_operations
diff options
context:
space:
mode:
Diffstat (limited to 'src/other_tools/git_operations')
-rw-r--r--src/other_tools/git_operations/TARGETS6
-rw-r--r--src/other_tools/git_operations/git_repo_remote.cpp9
-rw-r--r--src/other_tools/git_operations/git_repo_remote.hpp3
3 files changed, 12 insertions, 6 deletions
diff --git a/src/other_tools/git_operations/TARGETS b/src/other_tools/git_operations/TARGETS
index 9d14f4bc..9a6aed5e 100644
--- a/src/other_tools/git_operations/TARGETS
+++ b/src/other_tools/git_operations/TARGETS
@@ -26,13 +26,15 @@
, "name": ["git_repo_remote"]
, "hdrs": ["git_repo_remote.hpp"]
, "srcs": ["git_repo_remote.cpp"]
- , "deps": [["src/buildtool/file_system", "git_repo"]]
+ , "deps":
+ [ ["src/buildtool/file_system", "git_repo"]
+ , ["src/buildtool/storage", "config"]
+ ]
, "stage": ["src", "other_tools", "git_operations"]
, "private-deps":
[ ["src/buildtool/logging", "log_level"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/file_system", "git_utils"]
- , ["src/buildtool/storage", "config"]
, ["@", "fmt", "", "fmt"]
, ["", "libgit2"]
, ["@", "json", "", "json"]
diff --git a/src/other_tools/git_operations/git_repo_remote.cpp b/src/other_tools/git_operations/git_repo_remote.cpp
index 80a2f956..00114b50 100644
--- a/src/other_tools/git_operations/git_repo_remote.cpp
+++ b/src/other_tools/git_operations/git_repo_remote.cpp
@@ -22,7 +22,6 @@
#include "src/buildtool/file_system/git_utils.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
-#include "src/buildtool/storage/config.hpp"
#include "src/buildtool/system/system_command.hpp"
#include "src/other_tools/git_operations/git_config_settings.hpp"
@@ -397,6 +396,7 @@ auto GitRepoRemote::FetchFromRemote(std::shared_ptr<git_config> cfg,
}
auto GitRepoRemote::UpdateCommitViaTmpRepo(
+ StorageConfig const& storage_config,
std::string const& repo_url,
std::string const& branch,
std::vector<std::string> const& inherit_env,
@@ -405,7 +405,7 @@ auto GitRepoRemote::UpdateCommitViaTmpRepo(
anon_logger_ptr const& logger) const noexcept
-> std::optional<std::string> {
try {
- auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("update");
+ auto tmp_dir = storage_config.CreateTypedTmpDir("update");
if (not tmp_dir) {
(*logger)("Failed to create temp dir for running 'git ls-remote'",
/*fatal=*/true);
@@ -532,7 +532,8 @@ auto GitRepoRemote::UpdateCommitViaTmpRepo(
}
}
-auto GitRepoRemote::FetchViaTmpRepo(std::string const& repo_url,
+auto GitRepoRemote::FetchViaTmpRepo(StorageConfig const& storage_config,
+ std::string const& repo_url,
std::optional<std::string> const& branch,
std::vector<std::string> const& inherit_env,
std::string const& git_bin,
@@ -540,7 +541,7 @@ auto GitRepoRemote::FetchViaTmpRepo(std::string const& repo_url,
anon_logger_ptr const& logger) noexcept
-> bool {
try {
- auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("fetch");
+ auto tmp_dir = storage_config.CreateTypedTmpDir("fetch");
if (not tmp_dir) {
(*logger)("Failed to create temp dir for running 'git fetch'",
/*fatal=*/true);
diff --git a/src/other_tools/git_operations/git_repo_remote.hpp b/src/other_tools/git_operations/git_repo_remote.hpp
index c59fb48e..53987e58 100644
--- a/src/other_tools/git_operations/git_repo_remote.hpp
+++ b/src/other_tools/git_operations/git_repo_remote.hpp
@@ -22,6 +22,7 @@
#include <vector>
#include "src/buildtool/file_system/git_repo.hpp"
+#include "src/buildtool/storage/config.hpp"
extern "C" {
struct git_config;
@@ -87,6 +88,7 @@ class GitRepoRemote : public GitRepo {
/// 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(
+ StorageConfig const& storage_config,
std::string const& repo_url,
std::string const& branch,
std::vector<std::string> const& inherit_env,
@@ -103,6 +105,7 @@ class GitRepoRemote : public GitRepo {
/// Returns a success flag.
/// It guarantees the logger is called exactly once with fatal if failure.
[[nodiscard]] auto FetchViaTmpRepo(
+ StorageConfig const& storage_config,
std::string const& repo_url,
std::optional<std::string> const& branch,
std::vector<std::string> const& inherit_env,