diff options
author | 2022-05-29 23:25:06 +0400 | |
---|---|---|
committer | 2022-05-29 23:25:06 +0400 | |
commit | 2803e0a372e7dc745ab719485d4d6f42bbdae282 (patch) | |
tree | 5a1b8b2c09a08421e2c89deb10c75df68d73a4cd /docs/conf.py | |
parent | Declare Releases As Parallel-Read Safe (diff) |
Only Build Current Branch When Option Enabled
Changes the behavior of `BUILD_DOCS_FOR_HEAD` to add only the current
branch to the build whitelist, instead of all branches.
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'docs/conf.py')
-rw-r--r-- | docs/conf.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/docs/conf.py b/docs/conf.py index c4f24035..386303dd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,10 +7,14 @@ import shutil import sys from pathlib import Path +import git import releases +import sphinx.util.logging import tomli from sphinx.application import Sphinx +logger = sphinx.util.logging.getLogger(__name__) + # Handle the path not being set correctly in actions. sys.path.insert(0, os.path.abspath('..')) @@ -201,6 +205,14 @@ releases.setup = _releases_setup # unless `BUILD_DOCS_FOR_HEAD` env variable is True. smv_remote_whitelist = None smv_latest_version = "main" -if os.getenv("BUILD_DOCS_FOR_HEAD", "False").lower() == "false": - smv_branch_whitelist = "main" + +smv_branch_whitelist = "main" +if os.getenv("BUILD_DOCS_FOR_HEAD", "False").lower() == "true": + try: + branch = git.Repo(PROJECT_ROOT).active_branch.name + logger.info(f"Adding branch {branch} to build whitelist") + smv_branch_whitelist = f"main|{branch}" + except git.InvalidGitRepositoryError: + pass + smv_tag_whitelist = r"v(?!([0-6]\.)|(7\.[0-1]\.0))" # Don't include any versions prior to v7.1.1 |