Skip to content

Commit 3341026

Browse files
authored
Use Git.jl for git operations (#2348)
1 parent ae0188b commit 3341026

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
* Documenter prints a more informative warning now if there is unexpected Julia interpolation in the Markdown (e.g. from errant `$` signs). ([#2288], [#2327])
1212
* Documenter now warns when it encounters invalid keys in the various key-value at-blocks. ([#2306], [#2324])
1313
* File sizes are now expressed in more human-readable format. ([#2272], [#2344])
14+
* Documenter now uses [Git.jl](https://github.com/JuliaVersionControl/Git.jl) (as opposed to the system's `git` binary) for Git operations. ([#2348])
1415

1516
### Fixed
1617

@@ -1750,6 +1751,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
17501751
[#2329]: https://github.com/JuliaDocs/Documenter.jl/issues/2329
17511752
[#2330]: https://github.com/JuliaDocs/Documenter.jl/issues/2330
17521753
[#2344]: https://github.com/JuliaDocs/Documenter.jl/issues/2344
1754+
[#2348]: https://github.com/JuliaDocs/Documenter.jl/issues/2348
17531755
[JuliaLang/julia#29344]: https://github.com/JuliaLang/julia/issues/29344
17541756
[JuliaLang/julia#36953]: https://github.com/JuliaLang/julia/issues/36953
17551757
[JuliaLang/julia#38054]: https://github.com/JuliaLang/julia/issues/38054

Project.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
99
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1010
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1111
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
12+
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
1213
IOCapture = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
1314
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
1415
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
@@ -31,6 +32,7 @@ Base64 = "1.6"
3132
Dates = "1.6"
3233
DocStringExtensions = "0.4, 0.5, 0.6, 0.7, 0.8, 0.9"
3334
Downloads = "1.4"
35+
Git = "1"
3436
IOCapture = "0.2"
3537
InteractiveUtils = "1.6"
3638
JSON = "0.19, 0.20, 0.21"
@@ -40,13 +42,13 @@ Markdown = "1.6"
4042
MarkdownAST = "0.1.1"
4143
Pkg = "1.6"
4244
PrecompileTools = "1"
43-
RegistryInstances = "0.1"
44-
Random = "1.6"
4545
REPL = "1.6"
46+
Random = "1.6"
47+
RegistryInstances = "0.1"
4648
SHA = "0.7, 1.6"
4749
Test = "1.6"
48-
Unicode = "1.6"
4950
UUIDs = "1.6"
51+
Unicode = "1.6"
5052
julia = "1.6"
5153

5254
[extras]

src/Documenter.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import REPL
2222
import Unicode
2323
import Pkg
2424
import RegistryInstances
25+
import Git
2526
# Additional imported names
2627
using Test: @testset, @test
2728
using DocStringExtensions

src/utilities/utilities.jl

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,16 +758,24 @@ dropheaders(v::Vector) = map(dropheaders, v)
758758
dropheaders(other) = other
759759

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

0 commit comments

Comments
 (0)