Skip to content

Commit

Permalink
Merge pull request #1216 from JuliaDocs/fe/dbg
Browse files Browse the repository at this point in the history
Force git to use the correct ssh config file
  • Loading branch information
fredrikekre authored Dec 15, 2019
2 parents 17df2f4 + 8201379 commit 75682ff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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])
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
49 changes: 14 additions & 35 deletions src/Documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

2 comments on commit 75682ff

@fredrikekre
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/6759

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.24.3 -m "<description of version>" 75682ff86367d43881740a6f44c116a96e369025
git push origin v0.24.3

Please sign in to comment.