Skip to content

Commit 7e69e6c

Browse files
committed
increment minor version
1 parent a10a249 commit 7e69e6c

File tree

3 files changed

+73
-71
lines changed

3 files changed

+73
-71
lines changed

GSASII/git_verinfo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- coding: utf-8 -*-
22
# git_verinfo.py - GSAS-II version info from git
3-
# Do not edit, generated by '../GSASII/install/incr-mini-version.py' script
4-
# Created 2025-04-25 12:08:55.967171-05:00
3+
# Do not edit, generated by 'GSASII/install/incr-minor-version.py' script
4+
# Created 2025-04-27 23:01:05.797041-05:00
55

6-
git_version = 'f41fd979e3bd50c706a44b281b52a5ed3dcb0013'
7-
git_tags = []
6+
git_version = 'a10a2498ca4d2ac80781d7288adb357af5893c66'
7+
git_tags = ['5807']
88
git_prevtaggedversion = 'dfc4cc57bfa3a65d8b086eac2dfcc470d4c95187'
99
git_prevtags = ['5806']
10-
git_versiontag = 'v5.3.3'
10+
git_versiontag = 'v5.4.0'

GSASII/install/incr-mini-version.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# create a new "mini" GSAS-II version number for the latest git check in.
2-
# (The version will change from from 5.X.Y to 5.X.Y+1)
3-
# Also record version info in the git_version.py file.
1+
# create a new numerical tag number for the most recent git checkin
2+
# and advance the "mini" GSAS-II version number (from 5.X.Y to 5.X.Y+1)
3+
# Record the hash and version numbers in the git_version.py file.
44

55
# This routine is used where the current version has not been
66
# given a numerical tag number
@@ -22,23 +22,31 @@
2222

2323
if __name__ == '__main__':
2424

25-
g2repo = git.Repo(path2repo)
26-
#if g2repo.active_branch.name != 'master':
27-
# print('Not on master branch')
28-
# sys.exit()
25+
try:
26+
g2repo = git.Repo(path2repo)
27+
except:
28+
print('Launch of gitpython for version file failed'+
29+
f' with path {path2repo}')
30+
sys.exit()
31+
if g2repo.active_branch.name != 'main':
32+
print('Not on main branch')
33+
sys.exit()
2934
if g2repo.head.is_detached:
3035
print(f'Detached head {commit0[:7]!r}')
3136
sys.exit()
3237
# make a list of tags without a dash; get the largest numeric tag
3338
# someday use the packaging module (but no more dependencies for now)
39+
numtag = [i for i in g2repo.tags if '-' not in i.name]
40+
max_numeric = max([int(i.name) for i in numtag if i.name.isdecimal()])
3441
commit = g2repo.head.commit
3542
now = dt.datetime.now().replace(
3643
tzinfo=commit.committed_datetime.tzinfo)
3744
commit0 = commit.hexsha
45+
# is the newest commit tagged?
3846
tags0 = g2repo.git.tag('--points-at',commit)
3947
if tags0: tags0 = tags0.split('\n')
4048
if tags0:
41-
print(f'Current version is tagged as {tags0}. This is not the routine to use')
49+
print(f'Latest commit ({commit.hexsha[:7]}) is already tagged ({tags0}).')
4250
sys.exit()
4351

4452
# get the latest version number
@@ -51,7 +59,7 @@
5159
# mini can be integer, float or even have letters (5.2.1.1rc1)
5260
# for now, ignore anything with letters or decimals
5361
mini = max([int(i) for i in minis if i.isdecimal()])
54-
#latest = f'{major}.{minor}.{mini}'
62+
latest = f'{major}.{minor}.{mini}'
5563
nextmini = f'v{major}.{minor}.{mini+1}'
5664
#nextminor = f'v{major}.{minor+1}.0'
5765
versiontag = nextmini
@@ -63,17 +71,24 @@
6371
g2repo.create_tag(str(versiontag),ref=commit)
6472
print(f'created version # {versiontag} for {commit.hexsha[:7]}')
6573

66-
# code taken from save-versions.py
74+
# add a numeric tag to the newest commit as well
75+
tagnum = max_numeric + 1
76+
while str(tagnum) in g2repo.tags:
77+
print(f'Error: {tagnum} would be repeated')
78+
tagnum += 1
79+
g2repo.create_tag(str(tagnum),ref=commit)
80+
print(f'created tag {tagnum} for {commit.hexsha[:7]}')
81+
6782
tags0 = [i for i in g2repo.git.tag('--points-at',commit).split('\n') if i.isdecimal()]
6883
history = list(g2repo.iter_commits('HEAD'))
6984
for i in history[1:]:
7085
tags = g2repo.git.tag('--points-at',i)
7186
if not tags: continue
7287
commitm1 = i.hexsha
73-
#tagsm1 = tags.split('\n')
7488
tagsm1 = [i for i in tags.split('\n') if i.isdecimal()]
7589
if not tagsm1: continue
7690
break
91+
# create a file with GSAS-II version information
7792
pyfile = os.path.join(path2GSAS2,'git_verinfo.py')
7893
try:
7994
fp = open(pyfile,'w')
@@ -92,9 +107,12 @@
92107
fp.write(f'git_prevtaggedversion = {commitm1!r}\n')
93108
fp.write(f'git_prevtags = {tagsm1}\n')
94109
fp.write(f'git_versiontag = {versiontag!r}\n')
95-
#
96110
fp.close()
97111
print(f'Created git version file {pyfile} at {now} for {commit0[:7]!r}')
98112

99-
print('Now do:\n\t git add \n\t git commit \n\t git push \n\t git push --tags\n (try "git push origin HEAD --tags")')
100-
113+
g2repo.index.add([pyfile])
114+
g2repo.index.commit('increment mini version')
115+
g2repo.remote(name='origin').push()
116+
g2repo.remote(name='origin').push('--tags')
117+
118+
# print('Now do:\n\t git add \n\t git commit \n\t git push \n\t git push --tags\n (try "git push origin HEAD --tags")')
Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
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)
1+
# create a new numerical tag number for the most recent git checkin
2+
# and advance the minor GSAS-II version number (from 5.X.Y to 5.X+1.0)
3+
# Record the hash and version numbers in the git_version.py file.
44

5-
# perhaps someday this should be made automatic in some fashion (perhaps
6-
# not used on every check-in but don't go too many days/mods without a new
7-
# version #
8-
9-
# perhaps someday include as a clean (run on git add) or smudge
10-
# step (run on git pull).
11-
# Alternately, on commit/pull might get a count of how many untagged
12-
# check-ins there have been.
13-
#
14-
# [filter "createVersionFile"]
15-
# clean = python git_filters.py --tag-version
16-
# smudge = python git_filters.py --record-version
17-
# for debug of auto-run scripts, include a redirect in the script to
18-
# send output to a log file:
19-
# sys.stderr = sys.stdout = open('/tmp/gitfilter.log','a')
20-
#
215
import os
226
import sys
237
import datetime as dt
@@ -32,17 +16,33 @@
3216

3317
if __name__ == '__main__':
3418

35-
g2repo = git.Repo(path2repo)
36-
# if g2repo.active_branch.name != 'master':
37-
# print('Not on master branch')
38-
# sys.exit()
19+
try:
20+
g2repo = git.Repo(path2repo)
21+
except:
22+
print('Launch of gitpython for version file failed'+
23+
f' with path {path2repo}')
24+
sys.exit()
25+
if g2repo.active_branch.name != 'main':
26+
print('Not on main branch')
27+
sys.exit()
3928
if g2repo.head.is_detached:
4029
print(f'Detached head {commit0[:7]!r}')
4130
sys.exit()
4231
# make a list of tags without a dash; get the largest numeric tag
4332
# someday use the packaging module (but no more dependencies for now)
4433
numtag = [i for i in g2repo.tags if '-' not in i.name]
4534
max_numeric = max([int(i.name) for i in numtag if i.name.isdecimal()])
35+
commit = g2repo.head.commit
36+
now = dt.datetime.now().replace(
37+
tzinfo=commit.committed_datetime.tzinfo)
38+
commit0 = commit.hexsha
39+
# is the newest commit tagged?
40+
tags0 = g2repo.git.tag('--points-at',commit)
41+
if tags0: tags0 = tags0.split('\n')
42+
if tags0:
43+
print(f'Latest commit ({commit.hexsha[:7]}) is already tagged ({tags0}).')
44+
sys.exit()
45+
4646
# get the latest version number
4747
releases = [i for i in g2repo.tags if '.' in i.name and i.name.startswith('v')]
4848
majors = [i.name.split('.')[0][1:] for i in releases]
@@ -60,36 +60,19 @@
6060
if versiontag in releases:
6161
print(f'Versioning problem, generated next version {versiontag} already defined!')
6262
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}).')
6963
sys.exit()
70-
# add a tag to the newest commit
64+
if versiontag != '?':
65+
g2repo.create_tag(str(versiontag),ref=commit)
66+
print(f'created version # {versiontag} for {commit.hexsha[:7]}')
67+
68+
# add a numeric tag to the newest commit as well
7169
tagnum = max_numeric + 1
7270
while str(tagnum) in g2repo.tags:
7371
print(f'Error: {tagnum} would be repeated')
7472
tagnum += 1
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]}')
73+
g2repo.create_tag(str(tagnum),ref=commit)
74+
print(f'created tag {tagnum} for {commit.hexsha[:7]}')
8075

81-
# create a file with GSAS-II version information
82-
try:
83-
g2repo = git.Repo(path2repo)
84-
except:
85-
print('Launch of gitpython for version file failed'+
86-
f' with path {path2repo}')
87-
sys.exit()
88-
commit = g2repo.head.commit
89-
#ctim = commit.committed_datetime.strftime('%d-%b-%Y %H:%M')
90-
now = dt.datetime.now().replace(
91-
tzinfo=commit.committed_datetime.tzinfo)
92-
commit0 = commit.hexsha
9376
tags0 = [i for i in g2repo.git.tag('--points-at',commit).split('\n') if i.isdecimal()]
9477
history = list(g2repo.iter_commits('HEAD'))
9578
for i in history[1:]:
@@ -99,6 +82,7 @@
9982
tagsm1 = [i for i in tags.split('\n') if i.isdecimal()]
10083
if not tagsm1: continue
10184
break
85+
# create a file with GSAS-II version information
10286
pyfile = os.path.join(path2GSAS2,'git_verinfo.py')
10387
try:
10488
fp = open(pyfile,'w')
@@ -120,9 +104,9 @@
120104
fp.close()
121105
print(f'Created git version file {pyfile} at {now} for {commit0[:7]!r}')
122106

123-
print('Now do:\n\t git add \n\t git commit \n\t git push \n\t git push --tags\n (try "git push origin HEAD --tags")')
107+
g2repo.index.add([pyfile])
108+
g2repo.index.commit('increment minor version')
109+
g2repo.remote(name='origin').push()
110+
g2repo.remote(name='origin').push('--tags')
124111

125-
# Git 2.4 has added the push.followTags option to turn that flag on by default which you can set with:
126-
#
127-
# git config --global push.followTags true
128-
# or by adding followTags = true to the [push] section of your ~/.gitconfig file.
112+
# print('Now do:\n\t git add \n\t git commit \n\t git push \n\t git push --tags\n (try "git push origin HEAD --tags")')

0 commit comments

Comments
 (0)