8000 makeversionhdr should be unforgiving · litui/circuitpython@f11ef4c · GitHub
[go: up one dir, main page]

Skip to content

Commit f11ef4c

Browse files
committed
makeversionhdr should be unforgiving
Recently(?) github started making it the default to only copy a single branch (e.g., main) and NO TAGS into new forks. This makes the step of the build process that determines the CircuitPython version not work, because tags are expected to be present. When tags are not present, the version number is only a git hash. The version number ends up being 0.0.0. This causes problems with libraries that check for CircuitPython version to determine compatibility, among other things. We'll do other things to improve the situation, such as document it. But it'd also be good if the build stopped when this detectable condition occurs.
1 parent 8a568d1 commit f11ef4c

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

py/makeversionhdr.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,25 @@ def get_version_info_from_git():
5959
return git_tag, git_hash, ver
6060

6161

62-
def get_version_info_from_docs_conf():
63-
with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "conf.py")) as f:
64-
for line in f:
65-
if line.startswith("version = release = '"):
66-
ver = line.strip().split(" = ")[2].strip("'")
67-
git_tag = "v" + ver
68-
ver = ver.split(".")
69-
if len(ver) == 2:
70-
ver.append("0")
71-
return git_tag, "<no hash>", ver
72-
return None
62+
def cannot_determine_version():
63+
raise SystemExit(
64+
"""Cannot determine version.
65+
66+
CircuitPython must be built from a git clone with tags.
67+
If you cloned from a fork, fetch the tags from adafruit/circuitpython as follows:
68+
69+
git fetch --tags --recurse-submodules=no --shallow-since="2021-07-01" https://github.com/adafruit/circuitpython HEAD"""
70+
)
7371

7472

7573
def make_version_header(filename):
76-
# Get version info using git, with fallback to docs/conf.py
74+
# Get version info using git (required)
7775
info = get_version_info_from_git()
7876
if info is None:
79-
info = get_version_info_from_docs_conf()
80-
77+
cannot_determine_version()
8178
git_tag, git_hash, ver = info
8279
if len(ver) < 3:
83-
ver = ("0", "0", "0")
84-
version_string = git_hash
80+
cannot_determine_version()
8581
else:
8682
version_string = ".".join(ver)
8783

0 commit comments

Comments
 (0)
0