From a7cc305a3a6e2886a4f7ec7b8fd9943ff45f286d Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 20 Feb 2024 12:00:57 +0100 Subject: git repo fetch: support "inherit env" When fetching git repositories, just-mr routinely shells out to git. In this case, allow the user to specify via "inherit env", which environment variables from the host environment should be made available in this action. Typical variables to inherit are ones providing credentials, like SSH_AUTH_SOCK. As the repository description specifies the commit that will be taken, and hence the resulting tree, correctness is not affected by the environement leaking in here. --- src/other_tools/ops_maps/git_update_map.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/other_tools/ops_maps/git_update_map.cpp') diff --git a/src/other_tools/ops_maps/git_update_map.cpp b/src/other_tools/ops_maps/git_update_map.cpp index 157d13bb..0ce9de49 100644 --- a/src/other_tools/ops_maps/git_update_map.cpp +++ b/src/other_tools/ops_maps/git_update_map.cpp @@ -35,7 +35,7 @@ auto CreateGitUpdateMap(GitCASPtr const& git_cas, if (not git_repo) { (*logger)( fmt::format("Failed to open tmp Git repository for remote {}", - key.first), + key.repo), /*fatal=*/true); return; } @@ -43,7 +43,7 @@ auto CreateGitUpdateMap(GitCASPtr const& git_cas, if (not tmp_dir) { (*logger)(fmt::format("Failed to create commit update tmp dir for " "remote {}", - key.first), + key.repo), /*fatal=*/true); return; } @@ -55,11 +55,12 @@ auto CreateGitUpdateMap(GitCASPtr const& git_cas, fatal); }); // update commit - auto id = fmt::format("{}:{}", key.first, key.second); + auto id = fmt::format("{}:{}", key.repo, key.branch); JustMRProgress::Instance().TaskTracker().Start(id); auto new_commit = git_repo->UpdateCommitViaTmpRepo(tmp_dir->GetPath(), - key.first, - key.second, + key.repo, + key.branch, + key.inherit_env, git_bin, launcher, wrapped_logger); @@ -70,5 +71,6 @@ auto CreateGitUpdateMap(GitCASPtr const& git_cas, JustMRStatistics::Instance().IncrementExecutedCounter(); (*setter)(new_commit->c_str()); }; - return AsyncMapConsumer(update_commits, jobs); + return AsyncMapConsumer( + update_commits, jobs); } -- cgit v1.2.3