Skip to content

Commit

Permalink
Use Git.jl for git operations (#2348)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi authored Nov 26, 2023
1 parent ae0188b commit 3341026
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Documenter prints a more informative warning now if there is unexpected Julia interpolation in the Markdown (e.g. from errant `$` signs). ([#2288], [#2327])
* Documenter now warns when it encounters invalid keys in the various key-value at-blocks. ([#2306], [#2324])
* File sizes are now expressed in more human-readable format. ([#2272], [#2344])
* Documenter now uses [Git.jl](https://github.com/JuliaVersionControl/Git.jl) (as opposed to the system's `git` binary) for Git operations. ([#2348])

### Fixed

Expand Down Expand Up @@ -1750,6 +1751,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2329]: https://github.com/JuliaDocs/Documenter.jl/issues/2329
[#2330]: https://github.com/JuliaDocs/Documenter.jl/issues/2330
[#2344]: https://github.com/JuliaDocs/Documenter.jl/issues/2344
[#2348]: https://github.com/JuliaDocs/Documenter.jl/issues/2348
[JuliaLang/julia#29344]: https://github.com/JuliaLang/julia/issues/29344
[JuliaLang/julia#36953]: https://github.com/JuliaLang/julia/issues/36953
[JuliaLang/julia#38054]: https://github.com/JuliaLang/julia/issues/38054
Expand Down
8 changes: 5 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
IOCapture = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Expand All @@ -31,6 +32,7 @@ Base64 = "1.6"
Dates = "1.6"
DocStringExtensions = "0.4, 0.5, 0.6, 0.7, 0.8, 0.9"
Downloads = "1.4"
Git = "1"
IOCapture = "0.2"
InteractiveUtils = "1.6"
JSON = "0.19, 0.20, 0.21"
Expand All @@ -40,13 +42,13 @@ Markdown = "1.6"
MarkdownAST = "0.1.1"
Pkg = "1.6"
PrecompileTools = "1"
RegistryInstances = "0.1"
Random = "1.6"
REPL = "1.6"
Random = "1.6"
RegistryInstances = "0.1"
SHA = "0.7, 1.6"
Test = "1.6"
Unicode = "1.6"
UUIDs = "1.6"
Unicode = "1.6"
julia = "1.6"

[extras]
Expand Down
1 change: 1 addition & 0 deletions src/Documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import REPL
import Unicode
import Pkg
import RegistryInstances
import Git
# Additional imported names
using Test: @testset, @test
using DocStringExtensions
Expand Down
26 changes: 17 additions & 9 deletions src/utilities/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -758,16 +758,24 @@ dropheaders(v::Vector) = map(dropheaders, v)
dropheaders(other) = other

function git(; nothrow = false, kwargs...)
system_git_path = Sys.which("git")
if system_git_path === nothing
return nothrow ? nothing : error("Unable to find `git`")
end
# According to the Git man page, the default GIT_TEMPLATE_DIR is at /usr/share/git-core/templates
# We need to set this to something so that Git wouldn't pick up the user
# templates (e.g. from init.templateDir config).
cmd = addenv(`$(system_git_path)`, "GIT_TEMPLATE_DIR" => "/usr/share/git-core/templates")
# DOCUMENTER_KEY etc are never needed for git operations
cmd = addenv(cmd, NO_KEY_ENV)
cmd = addenv(Git.git(), NO_KEY_ENV)
if Sys.iswindows()
cmd = addenv(cmd,
# For deploydocs() in particular, we need to use symlinks, but it looks like those
# need to be explicitly force-enabled on Windows. So we make sure that we configure
# core.symlinks=true via environment variables on that platform.
"GIT_CONFIG_COUNT" => "1",
"GIT_CONFIG_KEY_0" => "core.symlinks",
"GIT_CONFIG_VALUE_0" => "true",
# Previously we used to set GIT_TEMPLATE_DIR=/usr/share/git-core/templates on all platforms.
# This was so that we wouldn't pick up the user's Git configuration. Git.jl, however, points
# the GIT_TEMPLATE_DIR to the artifact directory, and so we're mostly fine without setting
# now.. _except_ on Windows, where it doesn't set it. So we still set the environment variable
# on Windows, just in case.
"GIT_TEMPLATE_DIR" => "/usr/share/git-core/templates",
)
end
return cmd
end

Expand Down

0 comments on commit 3341026

Please sign in to comment.