Skip to content

Commit

Permalink
Update git.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
DilumAluthge authored Oct 31, 2023
1 parent a163bc2 commit 4e980db
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/utilities/git.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4e980db

Please sign in to comment.