From 77d7a671a8ca01a385a0bc92ba65639ffbea366e Mon Sep 17 00:00:00 2001 From: Duncan Macleod <macleoddm@cardiff.ac.uk> Date: Wed, 15 Jan 2025 11:58:16 +0000 Subject: [PATCH] docs: improve linkcode git ref handling --- docs/conf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 15f6d73..f59326b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -93,6 +93,12 @@ napoleon_use_rtype = False def _project_git_ref(version, prefix="v"): """Returns the git reference for the given full release version. """ + # handle builds in CI + if os.getenv("GITLAB_CI"): + return os.environ["CI_COMMIT_REF"] + if os.getenv("GITHUB_ACTIONS"): + return os.environ["GITHUB_SHA"] + # otherwise use the project metadata _setuptools_scm_version_regex = re.compile( r"\+g(\w+)(?:\Z|\.)", ) @@ -107,7 +113,7 @@ PROJECT_URL = getenv( "CI_PROJECT_URL", "https://git.ligo.org/computing/gwdatafind/client", ) -PROJECT_BLOB_URL = f"{PROJECT_URL}/-/blob/{PROJECT_GIT_REF}/{PROJECT_PATH.name}" +PROJECT_BLOB_URL = f"{PROJECT_URL}/blob/{PROJECT_GIT_REF}/{PROJECT_PATH.name}" def linkcode_resolve(domain, info): -- GitLab