Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small changes for GitLab #971

Merged
merged 6 commits into from
Mar 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
blocks are now interpreted to be relative `pwd`, which is set to the output directory of the
resulting file. ([#941][github-941])

* ![Bugfix][badge-bugfix] `deploydocs` and `git_push` now support non-github repos correctly and work when the `.ssh` directory does not already exist or the working directory contains spaces. ([#971][github-971])

## Version `v0.21.5`

* ![Bugfix][badge-bugfix] Deprecation warnings for `format` now get printed correctly when multiple formats are passed as a `Vector`. ([#967][github-967])
Expand Down Expand Up @@ -264,6 +266,7 @@
[github-959]: https://github.com/JuliaDocs/Documenter.jl/pull/959
[github-960]: https://github.com/JuliaDocs/Documenter.jl/pull/960
[github-967]: https://github.com/JuliaDocs/Documenter.jl/pull/967
[github-971]: https://github.com/JuliaDocs/Documenter.jl/pull/971

[documenterlatex]: https://github.com/JuliaDocs/DocumenterLaTeX.jl
[documentermarkdown]: https://github.com/JuliaDocs/DocumenterMarkdown.jl
Expand Down
20 changes: 16 additions & 4 deletions src/Documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,11 @@ function git_push(

target_dir = abspath(target)

# Extract host from repo as everything up to first ':' or '/' character
host = match(r"(.*?)[:\/]", repo)[1]

# The upstream URL to which we push new content and the ssh decryption commands.
upstream = "git@$(replace(repo, "github.com/" => "github.com:"))"
upstream = "git@$(replace(repo, "$host/" => "$host:"))"

keyfile = abspath(joinpath(root, ".documenter"))
try
Expand All @@ -626,10 +629,10 @@ function git_push(
# Use a custom SSH config file to avoid overwriting the default user config.
withfile(joinpath(homedir(), ".ssh", "config"),
"""
Host github.com
Host $host
StrictHostKeyChecking no
HostName github.com
IdentityFile $keyfile
HostName $host
IdentityFile "$keyfile"
BatchMode yes
"""
) do
Expand Down Expand Up @@ -747,6 +750,10 @@ function gitrm_copy(src, dst)
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
Expand All @@ -763,6 +770,11 @@ function withfile(func, file::AbstractString, contents::AbstractString)
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

Expand Down