Skip to content

Commit 62a86bd

Browse files
committed
Extract exact version from a tagged git archive.
Produce exact version with GitHub zip archives from the releases/tags page. No need to upload sdist archives anymore.
1 parent 742af86 commit 62a86bd

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Diff for: diffpy/Structure/gitarchive.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
commit = $Format:%H$
33
date = $Format:%ai$
44
timestamp = $Format:%at$
5+
refnames = $Format:%D$

Diff for: setup.py

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def gitinfo():
3232

3333

3434
def getversioncfg():
35+
import re
3536
from ConfigParser import RawConfigParser
3637
vd0 = dict(version=FALLBACK_VERSION, commit='', date='', timestamp=0)
3738
# first fetch data from gitarchivecfgfile, ignore if it is unexpanded
@@ -40,6 +41,9 @@ def getversioncfg():
4041
cp0.read(gitarchivecfgfile)
4142
if '$Format:' not in cp0.get('DEFAULT', 'commit'):
4243
g = cp0.defaults()
44+
mx = re.search(r'\btag: v(\d[^,]*)', g.pop('refnames'))
45+
if mx:
46+
g['version'] = mx.group(1)
4347
# then try to obtain version data from git.
4448
gitdir = os.path.join(MYDIR, '.git')
4549
if os.path.exists(gitdir) or 'GIT_DIR' in os.environ:

0 commit comments

Comments
 (0)