Skip to content

Commit e93665d

Browse files
committed
Merge remote-tracking branch 'remotes/origin/master'
2 parents 8f83671 + d5f47f7 commit e93665d

File tree

3 files changed

+71
-48
lines changed

3 files changed

+71
-48
lines changed

GSASII/git_verinfo.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# -*- coding: utf-8 -*-
22
# git_verinfo.py - GSAS-II version info from git
3-
# Do not edit, generated by 'GSASII/install/tag-version.py' command
4-
# Created 2025-02-14 11:35:30.542273-06:00
3+
# Do not edit, generated by 'GSASII/install/tag-version.py' script
4+
# Created 2025-02-23 10:15:56.232853-06:00
55

6-
git_version = '88aaa86a1f1a5a723dfe63f94dfb82f9d2b8eb48'
7-
git_tags = ['5803']
8-
git_prevtaggedversion = '45480f29835216e3376b2941edfbdba4de1f22dc'
9-
git_prevtags = ['5802']
6+
git_version = '0cc1b76caf527336878cb66f2eb4b103be22ead3'
7+
git_tags = ['5804']
8+
git_prevtaggedversion = '88aaa86a1f1a5a723dfe63f94dfb82f9d2b8eb48'
9+
git_prevtags = ['5803']
10+
git_versiontag = 'v5.1.0'

GSASII/imports/G2pwd_MIDAS.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ def ContentsValidator(self, filename):
6262
if all([(i in fp) for i in self.midassections]): # are expected MIDAS sections present?
6363
self.mode = 'midas'
6464
return True # must be present for Midas output
65-
except:
65+
except FileNotFoundError as msg:
66+
self.errors = f'Exception from zarr module (version={zarr.__version__}):'
67+
self.errors += '\n\t' + str(msg)
68+
if os.path.exists(filename) and zarr.__version__.startswith('3.0'):
69+
self.errors +='\n\n*** this is likely due to a buggy version of the zarr module'
70+
self.errors +='\n*** please use "conda install zarr=2.18" to fix this'
71+
except Exception as msg:
72+
self.errors = f'Exception from zarr module (version={zarr.__version__}):'
73+
self.errors += '\n\t' + str(msg)
6674
return False
6775
finally:
6876
del fp

GSASII/install/tag-version.py

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
# create tag number for the latest git check in and record that in
2-
# the git_version.py file.
1+
# create numerical tag number for the latest git check in and record that in
2+
# the git_version.py file. This also advances the minor version number
3+
# for the GSAS-II version number (from 5.X.Y to 5.X+1.0)
34

45
# perhaps someday this should be made automatic in some fashion (perhaps
5-
# not used on every check-in but don't go too many days/mosds without a new
6+
# not used on every check-in but don't go too many days/mods without a new
67
# version #
78

89
# perhaps someday include as a clean (run on git add) or smudge
9-
# step (run on git pull).
10+
# step (run on git pull).
1011
# Alternately, on commit/pull might get a count of how many untagged
11-
# check-ins there have been.
12+
# check-ins there have been.
1213
#
1314
# [filter "createVersionFile"]
1415
# clean = python git_filters.py --tag-version
@@ -30,61 +31,73 @@
3031
path2repo = os.path.dirname(path2GSAS2)
3132

3233
if __name__ == '__main__':
33-
34+
3435
g2repo = git.Repo(path2repo)
35-
if g2repo.active_branch.name != 'master':
36-
print(f'Not on master branch {commit0[:6]!r}')
37-
sys.exit()
38-
if g2repo.head.is_detached:
39-
print(f'Detached head {commit0[:6]!r}')
36+
# if g2repo.active_branch.name != 'master':
37+
# print('Not on master branch')
38+
# sys.exit()
39+
if g2repo.head.is_detached:
40+
print(f'Detached head {commit0[:7]!r}')
4041
sys.exit()
4142
# make a list of tags without a dash; get the largest numeric tag
43+
# someday use the packaging module (but no more dependencies for now)
4244
numtag = [i for i in g2repo.tags if '-' not in i.name]
4345
max_numeric = max([int(i.name) for i in numtag if i.name.isdecimal()])
44-
45-
# scan for the newest untagged commits, stopping at the first
46-
# tagged one
47-
untagged = []
48-
for i,c in enumerate(g2repo.iter_commits('HEAD')):
49-
if i > 500:
50-
print('No tag found in 500 commits!')
51-
#break
52-
sys.exit()
53-
tags = g2repo.git.tag('--points-at',c).split('\n')
54-
if tags == ['']:
55-
untagged.append(c)
56-
else:
57-
break
58-
# add a tag to the newest untagged version
59-
tagnum = max_numeric
60-
for i in sorted(untagged,key=lambda k:k.committed_datetime,reverse=True):
46+
# get the latest version number
47+
releases = [i for i in g2repo.tags if '.' in i.name and i.name.startswith('v')]
48+
majors = [i.name.split('.')[0][1:] for i in releases]
49+
major = max([int(i) for i in majors if i.isdecimal()])
50+
minors = [i.name.split('.')[1] for i in releases if i.name.startswith(f'v{major}.')]
51+
minor = max([int(i) for i in minors if i.isdecimal()])
52+
minis = [i.name.split('.',2)[2] for i in releases if i.name.startswith(f'v{major}.{minor}')]
53+
# mini can be integer, float or even have letters (5.2.1.1rc1)
54+
# for now, ignore anything with letters or decimals
55+
mini = max([int(i) for i in minis if i.isdecimal()])
56+
latest = f'{major}.{minor}.{mini}'
57+
#nextmini = f'v{major}.{minor}.{mini+1}'
58+
nextminor = f'v{major}.{minor+1}.0'
59+
versiontag = nextminor
60+
if versiontag in releases:
61+
print(f'Versioning problem, generated next version {versiontag} already defined!')
62+
versiontag = '?'
63+
64+
# is the newest commit tagged?
65+
c = g2repo.head.commit
66+
tags = g2repo.git.tag('--points-at',c).split('\n')
67+
if tags != ['']:
68+
print(f'Latest commit ({c.hexsha[:7]}) is already tagged ({tags}).')
69+
sys.exit()
70+
# add a tag to the newest commit
71+
tagnum = max_numeric + 1
72+
while str(tagnum) in g2repo.tags:
73+
print(f'Error: {tagnum} would be repeated')
6174
tagnum += 1
62-
if str(tagnum) in g2repo.tags:
63-
print(f'Error: {tagnum} would be repeated')
64-
break
65-
g2repo.create_tag(str(tagnum),ref=i)
66-
print(f'created tag {tagnum} for {i.hexsha[:6]}')
67-
break
75+
g2repo.create_tag(str(tagnum),ref=c)
76+
print(f'created tag {tagnum} for {c.hexsha[:7]}')
77+
if versiontag != '?':
78+
g2repo.create_tag(str(versiontag),ref=c)
79+
print(f'created version # {versiontag} for {c.hexsha[:7]}')
6880

69-
# create a file with GSAS-II version infomation
81+
# create a file with GSAS-II version information
7082
try:
7183
g2repo = git.Repo(path2repo)
7284
except:
7385
print('Launch of gitpython for version file failed'+
7486
f' with path {path2repo}')
7587
sys.exit()
7688
commit = g2repo.head.commit
77-
ctim = commit.committed_datetime.strftime('%d-%b-%Y %H:%M')
89+
#ctim = commit.committed_datetime.strftime('%d-%b-%Y %H:%M')
7890
now = dt.datetime.now().replace(
7991
tzinfo=commit.committed_datetime.tzinfo)
8092
commit0 = commit.hexsha
81-
tags0 = g2repo.git.tag('--points-at',commit).split('\n')
93+
tags0 = [i for i in g2repo.git.tag('--points-at',commit).split('\n') if i.isdecimal()]
8294
history = list(g2repo.iter_commits('HEAD'))
8395
for i in history[1:]:
8496
tags = g2repo.git.tag('--points-at',i)
8597
if not tags: continue
8698
commitm1 = i.hexsha
87-
tagsm1 = tags.split('\n')
99+
tagsm1 = [i for i in tags.split('\n') if i.isdecimal()]
100+
if not tagsm1: continue
88101
break
89102
pyfile = os.path.join(path2GSAS2,'git_verinfo.py')
90103
try:
@@ -94,7 +107,7 @@
94107
sys.exit()
95108
fp.write('# -*- coding: utf-8 -*-\n')
96109
fp.write(f'# {os.path.split(pyfile)[1]} - GSAS-II version info from git\n')
97-
fp.write(f'# Do not edit, generated by {" ".join(sys.argv)!r} command\n')
110+
fp.write(f'# Do not edit, generated by {" ".join(sys.argv)!r} script\n')
98111
fp.write(f'# Created {now}\n\n')
99112
fp.write(f'git_version = {commit0!r}\n')
100113
if tags:
@@ -103,10 +116,11 @@
103116
fp.write('git_tags = []\n')
104117
fp.write(f'git_prevtaggedversion = {commitm1!r}\n')
105118
fp.write(f'git_prevtags = {tagsm1}\n')
119+
fp.write(f'git_versiontag = {versiontag!r}\n')
106120
fp.close()
107-
print(f'Created git version file {pyfile} at {now} for {commit0[:6]!r}')
121+
print(f'Created git version file {pyfile} at {now} for {commit0[:7]!r}')
108122

109-
print('Now do\n\t git add \n\t git commit \n\t git push \n\t git push --follow-tags (better than git push --tags?)')
123+
print('Now do:\n\t git add \n\t git commit \n\t git push \n\t git push --tags (better than git push --follow-tags?)')
110124

111125
# Git 2.4 has added the push.followTags option to turn that flag on by default which you can set with:
112126
#

0 commit comments

Comments
 (0)