From edb6803d5af1afe505164a62e1685b081d26995f Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 5 Jun 2017 17:06:31 +1200 Subject: [PATCH] Remove old files before copy in deploy (#510) This way we also commit case changes in file names on filesystems that are case-insensitive. Fixes #507 --- docs/make.jl | 1 + docs/src/lib/internals/documenter.md | 5 +++++ src/Documenter.jl | 24 ++++++++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 docs/src/lib/internals/documenter.md diff --git a/docs/make.jl b/docs/make.jl index 565860eb28..b324a290e9 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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", diff --git a/docs/src/lib/internals/documenter.md b/docs/src/lib/internals/documenter.md new file mode 100644 index 0000000000..83b4f10ba6 --- /dev/null +++ b/docs/src/lib/internals/documenter.md @@ -0,0 +1,5 @@ +# Documenter + +```@docs +Documenter.gitrm_copy +``` diff --git a/src/Documenter.jl b/src/Documenter.jl index c9f2a0c739..5028065e33 100644 --- a/src/Documenter.jl +++ b/src/Documenter.jl @@ -479,19 +479,19 @@ function deploydocs(; # Copy docs to `latest`, or `stable`, ``, and `` 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 @@ -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) : ""