diff --git a/src/utilities/git.jl b/src/utilities/git.jl index 34534053..085cd5c7 100644 --- a/src/utilities/git.jl +++ b/src/utilities/git.jl @@ -32,10 +32,10 @@ function git_push( ) force_flag = force ? ["-f"] : [] name, email = get_git_name_and_email(; env=env) - git_ssh_command = _git_ssh_command(; pkey_filename) + git_ssh_command = _get_git_ssh_command(; pkey_filename) env2 = copy(ENV); env2["GIT_SSH_COMMAND"] = git_ssh_command - if pkey_filename === nothing + if isnothing(pkey_filename) true_remote = remote else # We need to convert the remote URL to SSH format. @@ -49,7 +49,7 @@ function git_push( return nothing end -function _git_ssh_command(; pkey_filename::Union{AbstractString,Nothing}) +function _get_git_ssh_command(; pkey_filename::Union{AbstractString,Nothing}) enable_ssh_verbose_str = get(ENV, "JULIA_COMPATHELPER_ENABLE_SSH_VERBOSE", "false") enable_ssh_verbose_b = parse(Bool, enable_ssh_verbose_str)::Bool ssh = enable_ssh_verbose_b ? "ssh -vvvv" : "ssh" @@ -91,9 +91,11 @@ function git_clone( local_path::AbstractString, pkey_filename::Union{AbstractString,Nothing}=nothing, ) - env2 = copy(ENV); - env2["GIT_SSH_COMMAND"] = _git_ssh_command(; pkey_filename) - @mock run(`git clone $url $local_path`) + withenv( + "GIT_SSH_COMMAND" => isnothing(pkey_filename) ? "ssh" : "ssh -i $pkey_filename" + ) do + @mock run(`git clone $url $local_path`) + end return nothing end