Merge pull request #6912 from jepler/makeversionhdr-unforgiving

makeversionhdr should be unforgiving
This commit is contained in:
Dan Halbert 2022-09-16 14:51:30 -04:00 committed by GitHub
commit 32d8dd425f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 16 deletions

View File

@ -59,29 +59,25 @@ def get_version_info_from_git():
return git_tag, git_hash, ver
def get_version_info_from_docs_conf():
with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "conf.py")) as f:
for line in f:
if line.startswith("version = release = '"):
ver = line.strip().split(" = ")[2].strip("'")
git_tag = "v" + ver
ver = ver.split(".")
if len(ver) == 2:
ver.append("0")
return git_tag, "<no hash>", ver
return None
def cannot_determine_version():
raise SystemExit(
"""Cannot determine version.
CircuitPython must be built from a git clone with tags.
If you cloned from a fork, fetch the tags from adafruit/circuitpython as follows:
git fetch --tags --recurse-submodules=no --shallow-since="2021-07-01" https://github.com/adafruit/circuitpython HEAD"""
)
def make_version_header(filename):
# Get version info using git, with fallback to docs/conf.py
# Get version info using git (required)
info = get_version_info_from_git()
if info is None:
info = get_version_info_from_docs_conf()
cannot_determine_version()
git_tag, git_hash, ver = info
if len(ver) < 3:
ver = ("0", "0", "0")
version_string = git_hash
cannot_determine_version()
else:
version_string = ".".join(ver)