Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update clones if they're present #61

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/MultiDocumenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,28 @@ function maybe_clone(docs::Vector{MultiDocRef})
if !isdir(doc.upstream)
@info "Upstream at $(doc.upstream) does not exist. `git clone`ing `$(doc.giturl)#$(doc.branch)`"
run(
`$(git()) clone --depth 1 $(doc.giturl) --branch $(doc.branch) --single-branch $(doc.upstream)`,
`$(git()) clone --depth 1 $(doc.giturl) --branch $(doc.branch) --single-branch --no-tags $(doc.upstream)`,
)
else
git_dir, git_worktree = abspath(joinpath(doc.upstream, ".git")), abspath(doc.upstream)
if !isdir(git_dir)
@warn "Unable to update existing clone at $(doc.upstream): .git/ directory missing"
continue
end
@info "Updating existing clone at $(doc.upstream)"
gitcmd = `$(git()) -C $(git_worktree) --git-dir=$(git_dir)`
try
if !success(`$(gitcmd) diff HEAD --exit-code`)
@warn "Existing clone at $(doc.upstream) has local changes -- not updating."
continue
end
run(`$(gitcmd) fetch origin $(doc.branch)`)
run(`$(gitcmd) checkout --detach origin/$(doc.branch)`)
catch e
# We're only interested in catching `git` errors here
isa(e, ProcessFailedException) || rethrow()
@error "Unable to update existing clone at $(doc.upstream)" exception = (e, catch_backtrace())
end
end
end
end
Expand Down