From 54248ca56898dbb6b1492f72e3348da8581fe104 Mon Sep 17 00:00:00 2001 From: burnettk Date: Tue, 21 Feb 2023 22:00:02 -0500 Subject: [PATCH] copy env so we are doing additive stuff rather than completely rewriting it --- .../services/git_service.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py index f7baba8c7..6ae385ad3 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py @@ -154,30 +154,31 @@ class GitService: cls, command: list[str], return_success_state: bool = False ) -> Union[subprocess.CompletedProcess[bytes], bool]: """Run_shell_command.""" - git_env_options = { - "GIT_COMMITTER_NAME": ( - current_app.config.get("SPIFFWORKFLOW_BACKEND_GIT_USERNAME") - or "unknown" - ), - "GIT_COMMITTER_EMAIL": ( - current_app.config.get("SPIFFWORKFLOW_BACKEND_GIT_USER_EMAIL") - or "unknown@example.org" - ), - } + my_env = os.environ.copy() + my_env["GIT_COMMITTER_NAME"] = ( + current_app.config.get("SPIFFWORKFLOW_BACKEND_GIT_USERNAME") or "unknown" + ) + + my_env["GIT_COMMITTER_EMAIL"] = ( + current_app.config.get("SPIFFWORKFLOW_BACKEND_GIT_USER_EMAIL") + or "unknown@example.org" + ) + # SSH authentication can be also provided via gitconfig. ssh_key_path = current_app.config.get( "SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH" ) if ssh_key_path is not None: - git_env_options["GIT_SSH_COMMAND"] = ( + my_env["GIT_SSH_COMMAND"] = ( "ssh -F /dev/null -o UserKnownHostsFile=/dev/null -o" " StrictHostKeyChecking=no -i %s" % ssh_key_path ) # this is fine since we pass the commands directly result = subprocess.run( # noqa - command, check=False, capture_output=True, env=git_env_options + command, check=False, capture_output=True, env=my_env ) + if return_success_state: return result.returncode == 0