Skip to content

Commit

Permalink
read-version: fallback to get_version when git describe fails (#4366)
Browse files Browse the repository at this point in the history
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 <hash>
 - 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 <hash>
 - 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.
  • Loading branch information
blackboxsw authored Aug 18, 2023
1 parent 842d045 commit 7263cb4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ doc8
furo
m2r2
pyyaml
sphinx
sphinx==7.1.2
sphinx-design
sphinx-copybutton
sphinx-notfound-page
7 changes: 6 additions & 1 deletion tools/read-version
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down

0 comments on commit 7263cb4

Please sign in to comment.