Skip to content

Commit 4e980db

Browse files
authored
Update git.jl
1 parent a163bc2 commit 4e980db

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/utilities/git.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ function git_push(
3232
)
3333
force_flag = force ? ["-f"] : []
3434
name, email = get_git_name_and_email(; env=env)
35-
git_ssh_command = _git_ssh_command(; pkey_filename)
35+
git_ssh_command = _get_git_ssh_command(; pkey_filename)
3636
env2 = copy(ENV);
3737
env2["GIT_SSH_COMMAND"] = git_ssh_command
38-
if pkey_filename === nothing
38+
if isnothing(pkey_filename)
3939
true_remote = remote
4040
else
4141
# We need to convert the remote URL to SSH format.
@@ -49,7 +49,7 @@ function git_push(
4949
return nothing
5050
end
5151

52-
function _git_ssh_command(; pkey_filename::Union{AbstractString,Nothing})
52+
function _get_git_ssh_command(; pkey_filename::Union{AbstractString,Nothing})
5353
enable_ssh_verbose_str = get(ENV, "JULIA_COMPATHELPER_ENABLE_SSH_VERBOSE", "false")
5454
enable_ssh_verbose_b = parse(Bool, enable_ssh_verbose_str)::Bool
5555
ssh = enable_ssh_verbose_b ? "ssh -vvvv" : "ssh"
@@ -91,9 +91,11 @@ function git_clone(
9191
local_path::AbstractString,
9292
pkey_filename::Union{AbstractString,Nothing}=nothing,
9393
)
94-
env2 = copy(ENV);
95-
env2["GIT_SSH_COMMAND"] = _git_ssh_command(; pkey_filename)
96-
@mock run(`git clone $url $local_path`)
94+
withenv(
95+
"GIT_SSH_COMMAND" => isnothing(pkey_filename) ? "ssh" : "ssh -i $pkey_filename"
96+
) do
97+
@mock run(`git clone $url $local_path`)
98+
end
9799

98100
return nothing
99101
end

0 commit comments

Comments
 (0)