Skip to content

Commit

Permalink
monodocs - gracefully handle case when external repo doesn't contain …
Browse files Browse the repository at this point in the history
…tags: use current commit (#4598)
  • Loading branch information
cosmicBboy authored Dec 14, 2023
1 parent d5f0002 commit 76e373c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions docs/_ext/import_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,20 @@ def import_projects(app: Sphinx, config: Config):
local_docs_path = local_dir / project.docs_path
dest_docs_dir = srcdir / project.dest

# use the latest git tag when building docs
if repo:
tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime)
tag = tags[-1]
update_html_context(project, str(tag), str(tag.commit)[:7], config)
repo.git.checkout(str(tag))
if not tags:
# If tags don't exist just use the current commit. This occurs
# when the git repo is a shallow clone.
tag_str = "dev"
commit = repo.head.commit
else:
tag = tags[-1]
tag_str = str(tag)
commit = str(tag.commit)[:7]
repo.git.checkout(tag_str)

update_html_context(project, tag_str, commit, config)

if project.refresh or not dest_docs_dir.exists():
shutil.rmtree(dest_docs_dir, ignore_errors=True)
Expand Down

0 comments on commit 76e373c

Please sign in to comment.