From 7263cb48952446d8b2855bba7a0e0625c1557c9e Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Fri, 18 Aug 2023 14:40:29 -0600 Subject: [PATCH] read-version: fallback to get_version when git describe fails (#4366) Annotated git tags are not present in shallow git clones. In shallow clones, git describe may fail with exit 128 with one of the following errors: - No tags can describe - No names found, cannot describe anything If either message is present, fallback to cloudinit.version.version_string. This fixes readthedocs CI builds which may use git clone --depth 1 in Annotated git tags are not present in shallow git clones. In shallow clones, git describe may fail with exit 128 with one of the following errors: - No tags can describe - No names found, cannot describe anything If either message is present, fallback to cloudinit.version.version_string. Also pin sphinx=7.1.2 as the release 7.2.0 on August 17 dropped the extension setup_js_tag_helper used by our sphinx builds. This fixes readthedocs CI builds which may use git clone --depth 1 in the doc build process. --- doc-requirements.txt | 2 +- tools/read-version | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc-requirements.txt b/doc-requirements.txt index ee2126b091c..abc38cf4592 100644 --- a/doc-requirements.txt +++ b/doc-requirements.txt @@ -2,7 +2,7 @@ doc8 furo m2r2 pyyaml -sphinx +sphinx==7.1.2 sphinx-design sphinx-copybutton sphinx-notfound-page diff --git a/tools/read-version b/tools/read-version index 87c7ec76465..f47edd1523a 100755 --- a/tools/read-version +++ b/tools/read-version @@ -89,7 +89,12 @@ def get_version_from_git( version = tiny_p(cmd).strip() version_long = tiny_p(cmd + ["--long"]).strip() except subprocess.CalledProcessError as e: - if "No tags can describe" not in e.stderr: + if not any( + [ + "No tags can describe" in e.stderr, + "cannot describe anything" in e.stderr, + ] + ): raise version = src_version version_long = ""