diff --git a/CHANGELOG.md b/CHANGELOG.md index bf4b4c3b5d..4a0de06c74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased * ![Enhancement][badge-enhancement] MathJax 3 has been updated to `v3.2.0` (minor version bump). ([#1743][github-1743]) +* ![Enhancement][badge-enhancement] Documenter now tries to detect the development branch using `git` with the old default (`master`) as fallback. If you use `main` as the development branch you shouldn't need to specify `devbranch = "main"` as an argument to deploydocs anymore. ([#1443][github-1443], [#1727][github-1727], [#1751][github-1751]) ## Version `v0.27.10` @@ -860,6 +861,7 @@ [github-1441]: https://github.com/JuliaDocs/Documenter.jl/pull/1441 [github-1448]: https://github.com/JuliaDocs/Documenter.jl/pull/1448 [github-1440]: https://github.com/JuliaDocs/Documenter.jl/pull/1440 +[github-1443]: https://github.com/JuliaDocs/Documenter.jl/issues/1443 [github-1449]: https://github.com/JuliaDocs/Documenter.jl/issues/1449 [github-1452]: https://github.com/JuliaDocs/Documenter.jl/pull/1452 [github-1456]: https://github.com/JuliaDocs/Documenter.jl/pull/1456 @@ -946,7 +948,9 @@ [github-1706]: https://github.com/JuliaDocs/Documenter.jl/pull/1706 [github-1709]: https://github.com/JuliaDocs/Documenter.jl/pull/1709 [github-1716]: https://github.com/JuliaDocs/Documenter.jl/pull/1716 +[github-1727]: https://github.com/JuliaDocs/Documenter.jl/pull/1727 [github-1743]: https://github.com/JuliaDocs/Documenter.jl/pull/1743 +[github-1751]: https://github.com/JuliaDocs/Documenter.jl/pull/1751 [julia-38079]: https://github.com/JuliaLang/julia/issues/38079 [julia-39841]: https://github.com/JuliaLang/julia/pull/39841 diff --git a/src/Documenter.jl b/src/Documenter.jl index b817173e22..e664e65319 100644 --- a/src/Documenter.jl +++ b/src/Documenter.jl @@ -329,7 +329,7 @@ include("deployconfig.jl") branch = "gh-pages", deps = nothing | , make = nothing | , - devbranch = "master", + devbranch = nothing, devurl = "dev", versions = ["stable" => "v^", "v#.#", devurl => devurl], forcepush = false, @@ -415,7 +415,8 @@ deps = Deps.pip("pygments", "mkdocs") executed. **`devbranch`** is the branch that "tracks" the in-development version of the generated -documentation. By default this value is set to `"master"`. +documentation. By default Documenter tries to figure this out using `git`. Can be set +explicitly as a string (typically `"master"` or `"main"`). **`devurl`** the folder that in-development version of the docs will be deployed. Defaults to `"dev"`. @@ -491,7 +492,7 @@ function deploydocs(; deps = nothing, make = nothing, - devbranch = "master", + devbranch = nothing, devurl = "dev", versions = ["stable" => "v^", "v#.#", devurl => devurl], forcepush::Bool = false, @@ -499,6 +500,17 @@ function deploydocs(; push_preview::Bool = false, ) + # Try to figure out default branch (see #1443 and #1727) + if devbranch === nothing + str = try + read(pipeline(ignorestatus(setenv(`git remote show origin`; dir=root)); stderr=devnull), String) + catch + "" + end + m = match(r"^\s*HEAD branch:\s*(.*)$"m, str) + devbranch = m === nothing ? "master" : String(m[1]) + end + deploy_decision = deploy_folder(deploy_config; branch=branch, branch_previews=branch_previews,