From 274ee28fb5d8d5dea123eaa9fc51fd83eeda145a Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 1 Mar 2024 18:07:04 +0100 Subject: SystemCommand: Transfer outfile responsibility to caller --- src/other_tools/git_operations/git_repo_remote.cpp | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/other_tools/git_operations/git_repo_remote.cpp') diff --git a/src/other_tools/git_operations/git_repo_remote.cpp b/src/other_tools/git_operations/git_repo_remote.cpp index f3964e74..706eedae 100644 --- a/src/other_tools/git_operations/git_repo_remote.cpp +++ b/src/other_tools/git_operations/git_repo_remote.cpp @@ -459,13 +459,13 @@ auto GitRepoRemote::UpdateCommitViaTmpRepo( } // set up the system command SystemCommand system{repo_url}; - auto const command_output = + auto const exit_code = system.Execute(cmdline, env, GetGitPath(), // which path is not actually relevant tmp_path); - if (not command_output) { + if (not exit_code) { (*logger)(fmt::format("exec() on command failed."), /*fatal=*/true); return std::nullopt; @@ -473,15 +473,14 @@ auto GitRepoRemote::UpdateCommitViaTmpRepo( // output file can be read anyway std::string out_str{}; - auto cmd_out = FileSystemManager::ReadFile(command_output->stdout_file); + auto cmd_out = FileSystemManager::ReadFile(tmp_path / "stdout"); if (cmd_out) { out_str = *cmd_out; } // check for command failure - if (command_output->return_value != 0) { + if (*exit_code != 0) { std::string err_str{}; - auto cmd_err = - FileSystemManager::ReadFile(command_output->stderr_file); + auto cmd_err = FileSystemManager::ReadFile(tmp_path / "stderr"); if (cmd_err) { err_str = *cmd_err; @@ -618,22 +617,20 @@ auto GitRepoRemote::FetchViaTmpRepo(std::string const& repo_url, } // run command SystemCommand system{repo_url}; - auto const command_output = + auto const exit_code = system.Execute(cmdline, env, GetGitPath(), tmp_path); - if (not command_output) { + if (not exit_code) { (*logger)(fmt::format("exec() on command failed."), /*fatal=*/true); return false; } - if (command_output->return_value != 0) { + if (*exit_code != 0) { std::string out_str{}; std::string err_str{}; - auto cmd_out = - FileSystemManager::ReadFile(command_output->stdout_file); - auto cmd_err = - FileSystemManager::ReadFile(command_output->stderr_file); + auto cmd_out = FileSystemManager::ReadFile(tmp_path / "stdout"); + auto cmd_err = FileSystemManager::ReadFile(tmp_path / "stderr"); if (cmd_out) { out_str = *cmd_out; } -- cgit v1.2.3