Skip to content

Commit a15cf26

Browse files
authored
Merge pull request #74 from SYMSCAE/gitinfo
refactor: decouple fallback version from Git tags
2 parents 08a601a + 3981396 commit a15cf26

4 files changed

Lines changed: 41 additions & 26 deletions

File tree

‎.github/ISSUE_TEMPLATE/release_checklist.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ assignees: ""
1414
- [ ] Locally rendered documentation contains all appropriate pages and other human-written text is up-to-date with any changes in the code.
1515
- [ ] Installation instructions in the README, documentation, and the website are updated.
1616
- [ ] Grammar and writing quality are checked (no typos).
17-
- [ ] `FALLBACK_VERSION` in `site_scons/fallback_version.py` is updated to `<version-number>.post0`. Without this, the SCons build fails after tagging.
17+
- [ ] Review `FALLBACK_VERSION` in `site_scons/fallback_version.py` for builds without a resolvable release tag.
1818
- [ ] `scons test` passes locally with the latest conda-forge compilers and dependencies.
1919
- [ ] Dispatch matrix testing to test the release on all systems. If you do not have permission to run this workflow, tag the maintainer and say `@maintainer, please dispatch matrix testing workflow`. Matrix testing also runs automatically after a GitHub release is published, but it does not block the release, so check that it passes.
2020

@@ -23,6 +23,7 @@ Please tag the maintainer (e.g., @username) in the comment here when you are rea
2323
### GitHub full-release preparation checklist:
2424

2525
- [ ] The rc GitHub release and its source tarball appear correctly on the releases page.
26+
- [ ] Build the release source tarball without a Git checkout and verify that its version matches the release tag (with `X.Y.Z-rc.N` normalized to `X.Y.ZrcN`).
2627
- [ ] Docs are deployed successfully to `https://www.diffpy.org/libdiffpy`.
2728
- [ ] Successfully run all tests and do functional testing, e.g., with `diffpy.srreal` built against the rc.
2829

‎news/fallback-version.rst‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* Allow updating the fallback version before tagging a release by using it
20+
only when no version can be determined from Git or source archive tags.
21+
22+
**Security:**
23+
24+
* <news item>

‎site_scons/fallback_version.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
"""Definition of FALLBACK_VERSION.
44
5-
Use it when git repository is not available for example, when building
6-
from git zip archive.
5+
Use it when a checkout or source archive has no release tag from which
6+
to determine the version.
77
8-
Update FALLBACK_VERSION when tagging a new release.
8+
Review FALLBACK_VERSION before a release.
99
"""
1010

11-
FALLBACK_VERSION = "1.4.1.post0"
11+
FALLBACK_VERSION = "1.5.0rc0.post0"

‎site_scons/libdiffpybuildutils.py‎

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
https://github.com/diffpy/libdiffpy/releases
1616
"""
1717

18-
EMSG_BAD_FALLBACK_VERSION = """
19-
Inconsistent FALLBACK_VERSION {} vs {} from git tag.
20-
"""
21-
2218
RELEASE_TAG = re.compile(r"([0-9]+\.[0-9]+\.[0-9]+)(?:-rc\.([0-9]+))?")
2319

2420

@@ -71,18 +67,9 @@ def gitinfo():
7167
def getversion():
7268
"""Extract version from gitinfo and/or gitarchive.cfg file.
7369
74-
Process gitinfo first and make sure it matches FALLBACK_VERSION in
75-
fallback_version.py. Use expanded data from gitarchive.cfg when
76-
these sources are from git archive bundle.
70+
Prefer the version from gitinfo or an expanded git archive tag. Use
71+
FALLBACK_VERSION only when neither provides a version.
7772
"""
78-
from fallback_version import FALLBACK_VERSION
79-
80-
if not re.fullmatch(
81-
r"[0-9]+\.[0-9]+\.[0-9]+(?:rc[0-9]+)?\.post0", FALLBACK_VERSION
82-
):
83-
raise RuntimeError(
84-
"FALLBACK_VERSION must be X.Y.Z.post0 or X.Y.ZrcN.post0."
85-
)
8673
gitarchivecfgfile = os.path.join(MYDIR, "gitarchive.cfg")
8774
assert os.path.isfile(gitarchivecfgfile)
8875
with open(gitarchivecfgfile) as fp:
@@ -102,12 +89,15 @@ def getversion():
10289
gi["patchnumber"] = 0
10390
break
10491
rv.update(gi)
105-
if "version" in gi:
106-
afb = FALLBACK_VERSION
107-
gfb = gi["version"].split(".post")[0] + ".post0"
108-
if gfb != afb:
109-
raise RuntimeError(EMSG_BAD_FALLBACK_VERSION.format(afb, gfb))
110-
else:
92+
if "version" not in gi:
93+
from fallback_version import FALLBACK_VERSION
94+
95+
if not re.fullmatch(
96+
r"[0-9]+\.[0-9]+\.[0-9]+(?:rc[0-9]+)?\.post0", FALLBACK_VERSION
97+
):
98+
raise RuntimeError(
99+
"FALLBACK_VERSION must be X.Y.Z.post0 or X.Y.ZrcN.post0."
100+
)
111101
# A development checkout without a new-format tag, or an untagged
112102
# archive, has no known commit count. Keep the fallback version.
113103
rv["version"] = FALLBACK_VERSION

0 commit comments

Comments
 (0)