Skip to content

Commit c7354d8

Browse files
committed
Merge remote-tracking branch 'origin/main' into mp/fix-windows-ci
2 parents ec641b0 + 20093b5 commit c7354d8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/MultiDocumenter.jl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,28 @@ function maybe_clone(docs::Vector{MultiDocRef})
252252
if !isdir(doc.upstream)
253253
@info "Upstream at $(doc.upstream) does not exist. `git clone`ing `$(doc.giturl)#$(doc.branch)`"
254254
run(
255-
`$(git()) clone --depth 1 $(doc.giturl) --branch $(doc.branch) --single-branch $(doc.upstream)`,
255+
`$(git()) clone --depth 1 $(doc.giturl) --branch $(doc.branch) --single-branch --no-tags $(doc.upstream)`,
256256
)
257+
else
258+
git_dir, git_worktree = abspath(joinpath(doc.upstream, ".git")), abspath(doc.upstream)
259+
if !isdir(git_dir)
260+
@warn "Unable to update existing clone at $(doc.upstream): .git/ directory missing"
261+
continue
262+
end
263+
@info "Updating existing clone at $(doc.upstream)"
264+
gitcmd = `$(git()) -C $(git_worktree) --git-dir=$(git_dir)`
265+
try
266+
if !success(`$(gitcmd) diff HEAD --exit-code`)
267+
@warn "Existing clone at $(doc.upstream) has local changes -- not updating."
268+
continue
269+
end
270+
run(`$(gitcmd) fetch origin $(doc.branch)`)
271+
run(`$(gitcmd) checkout --detach origin/$(doc.branch)`)
272+
catch e
273+
# We're only interested in catching `git` errors here
274+
isa(e, ProcessFailedException) || rethrow()
275+
@error "Unable to update existing clone at $(doc.upstream)" exception = (e, catch_backtrace())
276+
end
257277
end
258278
end
259279
end

0 commit comments

Comments
 (0)