From a70aab99a4976585fb2ea4d02c29d192906e0f63 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Fri, 13 Dec 2019 15:51:46 +0100 Subject: [PATCH 1/2] Force git to use the correct ssh config file, fixes #1215. --- src/Documenter.jl | 49 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/src/Documenter.jl b/src/Documenter.jl index 35907fa302..ea2d20cf78 100644 --- a/src/Documenter.jl +++ b/src/Documenter.jl @@ -481,11 +481,14 @@ function git_push( target_dir = abspath(target) # Generate a closure with common commands for ssh and https - function git_commands() + function git_commands(sshconfig=nothing) # Setup git. run(`git init`) run(`git config user.name "zeptodoctor"`) run(`git config user.email "44736852+zeptodoctor@users.noreply.github.com"`) + if sshconfig !== nothing + run(`git config core.sshCommand "ssh -F $(sshconfig)"`) + end # Fetch from remote and checkout the branch. run(`git remote add upstream $upstream`) @@ -572,8 +575,8 @@ function git_push( chmod(keyfile, 0o600) try - # Use a custom SSH config file to avoid overwriting the default user config. - withfile(joinpath(homedir(), ".ssh", "config"), + mktemp() do sshconfig, io + print(io, """ Host $host StrictHostKeyChecking no @@ -582,9 +585,14 @@ function git_push( IdentityFile "$keyfile" IdentitiesOnly yes BatchMode yes - """ - ) do - cd(git_commands, temp) + """) + close(io) + chmod(sshconfig, 0o600) + # git config core.sshCommand requires git 2.10.0, but + # GIT_SSH_COMMAND works from 2.3.0 so define both. + withenv("GIT_SSH_COMMAND" => "ssh -F $(sshconfig)") do + cd(() -> git_commands(sshconfig), temp) + end end post_status(deploy_config; repo=repo, type="success", subfolder=subfolder) catch e @@ -634,35 +642,6 @@ function gitrm_copy(src, dst) cp(src, dst; force=true) end -function withfile(func, file::AbstractString, contents::AbstractString) - dir = dirname(file) - hasdir = isdir(dir) - hasdir || mkpath(dir) - - hasfile = isfile(file) - original = hasfile ? read(file, String) : "" - open(file, "w") do stream - print(stream, contents) - flush(stream) # Make sure file is written before continuing. - end - try - func() - finally - if hasfile - open(file, "w") do stream - print(stream, original) - end - else - rm(file) - end - - if !hasdir - # dir should be empty now as the only file inside was deleted - rm(dir, recursive=true) - end - end -end - function getenv(regex::Regex) for (key, value) in ENV occursin(regex, key) && return value From 8201379e7d61b5c4eab60163ef8c70ec2230eabc Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sun, 15 Dec 2019 23:48:54 +0100 Subject: [PATCH 2/2] CHANGELOG entry + version bump for Documenter 0.24.3. --- CHANGELOG.md | 5 +++++ Project.toml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f37d510526..a75a9e724e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Documenter.jl changelog +## Version `v0.24.3` + +* ![Bugfix][badge-bugfix] Fix a case where Documenter's deployment would fail due to git picking up the wrong ssh config file on non-standard systems. ([#1216][github-1216]) + ## Version `v0.24.2` * ![Maintenance][badge-maintenance] Improvements to logging in `deploydocs`. ([#1195][github-1195]) @@ -494,6 +498,7 @@ [github-1189]: https://github.com/JuliaDocs/Documenter.jl/pull/1189 [github-1194]: https://github.com/JuliaDocs/Documenter.jl/pull/1194 [github-1195]: https://github.com/JuliaDocs/Documenter.jl/pull/1195 +[github-1216]: https://github.com/JuliaDocs/Documenter.jl/pull/1216 [documenterlatex]: https://github.com/JuliaDocs/DocumenterLaTeX.jl [documentermarkdown]: https://github.com/JuliaDocs/DocumenterMarkdown.jl diff --git a/Project.toml b/Project.toml index 394d49ffa4..76c59dc179 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Documenter" uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -version = "0.24.2" +version = "0.24.3" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"