|
18 | 18 | # Get version from camtools package
|
19 | 19 | version = ct.__version__
|
20 | 20 |
|
21 |
| -# Get git commit hash |
| 21 | +# When building a version-tagged commit, only use the version as "release". Otherwise, |
| 22 | +# use the version number and the git hash as "release". |
| 23 | +print("[Detecting docs version]") |
22 | 24 | try:
|
23 | 25 | git_hash = (
|
24 | 26 | subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
|
25 | 27 | .decode("ascii")
|
26 | 28 | .strip()
|
27 | 29 | )
|
28 |
| - release = f"{version}+{git_hash}" |
| 30 | + all_tags = ( |
| 31 | + subprocess.check_output(["git", "tag", "--list"]) |
| 32 | + .decode("ascii") |
| 33 | + .strip() |
| 34 | + .split() |
| 35 | + ) |
| 36 | + head_tags = ( |
| 37 | + subprocess.check_output(["git", "tag", "--points-at", "HEAD"]) |
| 38 | + .decode("ascii") |
| 39 | + .strip() |
| 40 | + .split() |
| 41 | + ) |
| 42 | + |
| 43 | + print(f"- Version : {version}") |
| 44 | + print(f"- Git hash : {git_hash}") |
| 45 | + print(f"- All tags : {all_tags}") |
| 46 | + print(f"- HEAD tags : {head_tags}") |
| 47 | + |
| 48 | + # Check if current commit has a version tag |
| 49 | + if f"v{version}" in head_tags: |
| 50 | + release = version |
| 51 | + status = f"({git_hash} is version tagged as v{version})" |
| 52 | + else: |
| 53 | + release = f"{version}+{git_hash}" |
| 54 | + status = "(not a version tagged commit)" |
| 55 | + print(f"- Docs version: {release} {status}") |
| 56 | + |
29 | 57 | except subprocess.CalledProcessError:
|
30 | 58 | release = version
|
| 59 | + print(f"- Docs version : {release} (cannot detect git information)") |
31 | 60 |
|
32 | 61 | project = "CamTools"
|
33 | 62 | copyright = "2024, Yixing Lao"
|
|
0 commit comments