Skip to content

Commit

Permalink
Remove old files before copy in deploy (#510)
Browse files Browse the repository at this point in the history
This way we also commit case changes in file names on filesystems that
are case-insensitive.

Fixes #507
  • Loading branch information
mortenpi authored Jun 5, 2017
1 parent a6dfdd2 commit edb6803
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ makedocs(
"lib/internals/cross-references.md",
"lib/internals/docchecks.md",
"lib/internals/docsystem.md",
"lib/internals/documenter.md",
"lib/internals/documents.md",
"lib/internals/dom.md",
"lib/internals/expanders.md",
Expand Down
5 changes: 5 additions & 0 deletions docs/src/lib/internals/documenter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Documenter

```@docs
Documenter.gitrm_copy
```
24 changes: 20 additions & 4 deletions src/Documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -479,19 +479,19 @@ function deploydocs(;

# Copy docs to `latest`, or `stable`, `<release>`, and `<version>` directories.
if isempty(travis_tag)
cp(target_dir, latest_dir; remove_destination = true)
gitrm_copy(target_dir, latest_dir)
Writers.HTMLWriter.generate_siteinfo_file(latest_dir, "latest")
else
cp(target_dir, stable_dir; remove_destination = true)
gitrm_copy(target_dir, stable_dir)
Writers.HTMLWriter.generate_siteinfo_file(stable_dir, "stable")
cp(target_dir, tagged_dir; remove_destination = true)
gitrm_copy(target_dir, tagged_dir)
Writers.HTMLWriter.generate_siteinfo_file(tagged_dir, travis_tag)
# Build a `release-*.*` folder as well when the travis tag is
# valid, which it *should* always be anyway.
if ismatch(Base.VERSION_REGEX, travis_tag)
local version = VersionNumber(travis_tag)
local release = "release-$(version.major).$(version.minor)"
cp(target_dir, joinpath(dirname, release); remove_destination = true)
gitrm_copy(target_dir, joinpath(dirname, release))
Writers.HTMLWriter.generate_siteinfo_file(joinpath(dirname, release), release)
end
end
Expand Down Expand Up @@ -520,6 +520,22 @@ function deploydocs(;
end
end

"""
gitrm_copy(src, dst)
Uses `git rm -r` to remove `dst` and then copies `src` to `dst`. Assumes that the working
directory is within the git repository of `dst` is when the function is called.
This is to get around [#507](https://github.com/JuliaDocs/Documenter.jl/issues/507) on
filesystems that are case-insensitive (e.g. on OS X, Windows). Without doing a `git rm`
first, `git add -A` will not detect case changes in filenames.
"""
function gitrm_copy(src, dst)
# --ignore-unmatch so that we wouldn't get errors if dst does not exist
run(`git rm -rf --ignore-unmatch $(dst)`)
cp(src, dst)
end

function withfile(func, file::AbstractString, contents::AbstractString)
local hasfile = isfile(file)
local original = hasfile ? readstring(file) : ""
Expand Down

0 comments on commit edb6803

Please sign in to comment.