Skip to content

Commit d996e4b

Browse files
committed
rework version tracking file (git_verinfo.py) and scripts that write that.
1 parent 8236576 commit d996e4b

File tree

4 files changed

+52
-52
lines changed

4 files changed

+52
-52
lines changed

GSASII/GSASIIpath.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,22 +210,22 @@ def HowIsG2Installed():
210210
def getSavedVersionInfo():
211211
'''Get version number information from a file written by install
212212
routines. This is faster than getting the information from git. Also,
213-
when GSAS-II is installed into Python, the files are no longer in
214-
a git repository so querying git is not possible.
213+
when GSAS-II is installed into Python, files are no longer in
214+
a git repository, so querying git is not possible.
215215
216-
The saved_version.py file is written by install/save_versions.py.
217-
The git_verinfo.py file is written by install/tag-version.py or
218-
by install/incr-mini-version.py. If both are present, use the
219-
saved_version.py file preferentially.
216+
The git_verinfo.py file is written by install/incr-version.py or
217+
by install/save_versions.py
218+
The saved_version.py file was previousl written by
219+
install/save_versions.py but this file is no longer in use.
220220
221221
:returns: a reference to the version variables or None if no
222222
version info file is found.
223223
'''
224-
try:
225-
from . import saved_version as gv
226-
return gv
227-
except:
228-
pass
224+
# try:
225+
# from . import saved_version as gv
226+
# return gv
227+
# except:
228+
# pass
229229
try:
230230
from . import git_verinfo as gv
231231
return gv

GSASII/install/incr-version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
print(f'Created git version file {pyfile} at {now} for {commit0[:7]!r}')
137137

138138
g2repo.index.add([pyfile])
139-
g2repo.index.commit('increment {mode} version')
139+
g2repo.index.commit(f'increment {mode} version: {versiontag}/{tagnum}')
140140
print('committed',pyfile,'mode=',mode)
141141
g2repo.remote(name='origin').push()
142142
g2repo.remotes.origin.push(versiontag)

GSASII/install/save-versions.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# record tag number and git hash into a saved_version.py file.
1+
# record tag number and git hash into a git_verinfo.py file.
22
#
33
import os
44
import sys
@@ -46,7 +46,22 @@
4646
tagsm1 = [i for i in tags.split('\n') if i.isdecimal()]
4747
if not tagsm1: continue
4848
break
49-
pyfile = os.path.join(path2GSAS2,'saved_version.py')
49+
# get the latest version number
50+
releases = [i for i in g2repo.tags if '.' in i.name and i.name.startswith('v')]
51+
if releases:
52+
majors = [i.name.split('.')[0][1:] for i in releases]
53+
major = max([int(i) for i in majors if i.isdecimal()])
54+
minors = [i.name.split('.')[1] for i in releases if i.name.startswith(f'v{major}.')]
55+
minor = max([int(i) for i in minors if i.isdecimal()])
56+
minis = [i.name.split('.',2)[2] for i in releases if i.name.startswith(f'v{major}.{minor}')]
57+
# mini can be integer, float or even have letters (5.2.1.1rc1)
58+
# for now, ignore anything with letters or decimals
59+
mini = max([int(i) for i in minis if i.isdecimal()])
60+
versiontag = f'v{major}.{minor}.{mini}'
61+
else:
62+
versiontag = '?'
63+
# create a file with GSAS-II version information
64+
pyfile = os.path.join(path2GSAS2,'git_verinfo.py')
5065
try:
5166
fp = open(pyfile,'w')
5267
except:
@@ -66,21 +81,7 @@
6681
fp.write(f'git_prevtags = {tagsm1}\n')
6782
else:
6883
fp.write(f'git_prevtags = []\n')
69-
# get the latest version number
70-
releases = [i for i in g2repo.tags if '.' in i.name and i.name.startswith('v')]
71-
if releases:
72-
majors = [i.name.split('.')[0][1:] for i in releases]
73-
major = max([int(i) for i in majors if i.isdecimal()])
74-
minors = [i.name.split('.')[1] for i in releases if i.name.startswith(f'v{major}.')]
75-
minor = max([int(i) for i in minors if i.isdecimal()])
76-
minis = [i.name.split('.',2)[2] for i in releases if i.name.startswith(f'v{major}.{minor}')]
77-
# mini can be integer, float or even have letters (5.2.1.1rc1)
78-
# for now, ignore anything with letters or decimals
79-
mini = max([int(i) for i in minis if i.isdecimal()])
80-
versiontag = f'v{major}.{minor}.{mini}'
81-
else:
82-
versiontag = '?'
8384
fp.write(f'git_versiontag = {versiontag!r}\n')
8485
#
8586
fp.close()
86-
print(f'Created git version file {pyfile} at {now} for {commit0[:6]!r}')
87+
print(f'Created git version file {pyfile} at {now} for {commit0[:7]!r}')

docs/source/versioning.rst

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Version numbering used in GSAS-II
44
Git commits
55
------------
66

7-
GSAS-II versions are numbered in several ways. Every time a change to one ore more
8-
GSAS-II source files is committed to a repo by the git source code management system git assigns the set of changes a 40 character hexadecimal "hash" code for that version. Usually the hash code is abbreviated to the first 6-8 characters, which is still likely to be unique. We will refer to this label as the git commit number.
7+
GSAS-II versions are numbered in several ways. Every time a change to one or more
8+
GSAS-II source files is committed to a repo by the git source code management system, git assigns the set of changes a 40 character hexadecimal "hash" code for that version. Usually the hash code is abbreviated to the first 6-8 characters, which is still likely to be unique. We refer to this label as the git commit number.
99

1010
Integer Tag numbers
1111
------------------------
@@ -15,48 +15,47 @@ When a significant change is made to GSAS-II, a developer can assign an integer
1515
Release version numbers
1616
------------------------
1717

18-
Software packaging systems require version numbers of the form X.Y.Z, where the numbers X, Y and Z are labeled as major, minor and micro release version numbers, such as 5.1.3. X and Y are integers. Z is allowed to have a decimal place (such as 5.1.3.1) or may contain letters (such as 5.4.0rc1), but at present GSAS-II will use an integers for Z as well. The software numbering system that GSAS-II uses is intended to follow -- more or less -- the "`effective versioning <https://jacobtomlinson.dev/effver/>`_" versioning concept, as implemented below:
18+
Software packaging systems require version numbers of the form X.Y.Z, where the numbers X, Y and Z are labeled as major, minor and micro release version numbers, such as 5.1.3. X and Y are integers. Z is allowed to have a decimal place (such as 5.1.3.1) or may contain letters (such as 5.4.0rc1), but at present GSAS-II will use integers for Z as well. The software numbering system that GSAS-II uses is intended to follow -- more or less -- the "`effective versioning <https://jacobtomlinson.dev/effver/>`_" numbering concept, as implemented below:
1919

2020
* The major release (starting at 5 in 2015) will be changed in GSAS-II when there are very significant changes in how the software is installed or functions that affect large portions of how the program operates. Users are advised to look carefully at the `GSAS-II home page <https://gsasii.github.io>`_ to see what has been changed.
2121

22-
* When relatively limited new capabilities are added to GSAS-II or a change is made in how a small section of the program functions, the minor release number is incremented, such as changing from 5.1.3 to 5.2.0. (Note that when the minor release is incremented, the micro release is set to 0.) This will usually be accompanied with a change to the integer tag number (see above). A change in the minor release indicates that while there may be some new functionality that would be useful to learn about, users can expect the GSAS-II to function pretty much as it did before, so it is not essential to consult the documentation.
22+
* When relatively limited new capabilities are added to GSAS-II or a change is made in how a small section of the program functions, the minor release number is incremented, such as changing from 5.1.3 to 5.2.0. (Note that when the minor release is incremented, the micro release is set to 0.) This will be accompanied with a change to the integer tag number (see above). A change in the minor release indicates that there is some new functionality in GSAS-II that might be useful for users to learn about or a significant change due to a bug.
2323

24-
* Changes to the micro version are made when a bug is fixed or a cosmetic change has been applied and where a new distribution is intended. Users will normally not need to consider the details of an update when only the micro version number is incremented and may not want to update every time there is a new micro version released. However, if a user reports a but and has been told that the problem has been addressed, they will want the latest version. Likewise, before reporting a bug, users are asked to please make sure that error occurs with the latest GSAS-II version. The developers may become cross after tracking down something that has been reported as not working, only to find that problem was already fixed. Not every change (git commit) with GSAS-II will be assigned a new micro version. If the change is a development that is not completed or does not introduce any new functionality (for example improvements to documentation), a new git commit tag will be generated but the mini version will not be incremented.
24+
* Changes to the micro version are made when a minor bug is fixed or a cosmetic change has been applied and where users are encouraged to update. Users will normally not need to consider the details of an update when only the micro version number is incremented and may not want to update every time there is a new micro version released. However, users should always test GSAS-II with the latest version before reporting a bug. The developers may become unhappy after tracking down something that has been reported as not working, only to find that problem was already fixed.
25+
26+
Not every change (git commit) for GSAS-II will be assigned a new micro version. If the change is a development that is not completed or does not introduce any new functionality (for example improvements to documentation) or is otherwise not of general interest, while a new git commit tag will be always generated, the mini version number will not be incremented.
2527

2628
Tools
2729
--------
2830

29-
At present three scripts are provided for developers to use to create or work with integer tag and release version numbers, to save having to review the git logs for previously assigned numbers. All of these scripts update the `git_verinfo.py` version file which is kept so that non-git installs of GSAS-II can report the currect version number.
31+
At present two scripts are provided for developers to use to create or work with integer tag and release version numbers, to save having to review the git logs for previously assigned numbers. All of these scripts update the `git_verinfo.py` version file which is kept so that non-git installs of GSAS-II can report the currect version number.
3032

31-
To assign a new integer tag number (and increment the minor version number), use script:
33+
To assign a new integer tag number and increment the mini version number, use script:
3234

33-
`.../GSASII/install/tag-version.py`
35+
`.../GSASII/install/incr-version.py` or
36+
`.../GSASII/install/incr-version.py mini`
3437

35-
This script is used when there are significant changes (possibly cumulative) to the
36-
code and a new release should be tagged both with a new integer tag number and
37-
minor version number. It updates the `git_verinfo.py` version file so that
38-
GSAS-II can quickly report the current version numbers.
38+
This command is used when there have been minor changes made in GSAS-II and
39+
the changes warrent a version number update (for example, due to a bug fix).
3940

40-
To increment only the mini version number, use script:
41+
To increment the minor version number, use the script with argument "minor":
4142

42-
`.../GSASII/install/incr-mini-version.py`
43+
`.../GSASII/install/incr-version.py minor`
4344

44-
This script is used when the have been minor changes made in GSAS-II and
45-
the changes warrent an update (for example, due to a bug fix). This cannot be used
46-
when a new integer tag number has been assigned to the
47-
current GSAS-II commit.
48-
It also updates the `git_verinfo.py` version file so that
49-
GSAS-II can quickly report the current version numbers.
45+
This is used when there are significant changes (possibly cumulative) to the
46+
code and a new release should be tagged both with a new integer tag number and
47+
the minor version number should be increased (e.g. 5.8.2 to 5.9.0).
48+
49+
For non-git installs, there is also this routine:
5050

5151
`.../GSASII/install/save-versions.py`
5252

53-
This script is used to save the latest version info in the `saved_version.py` file.
53+
This script is used to save the latest version info in the `git_verinfo.py` file.
5454
This file is created when a non-git install is made for GSAS-II so that the
5555
hash number for the current git version (which cannot be
56-
placed into the `git_verinfo.py` file) is recorded.
56+
placed into the `git_verinfo.py` file by the `incr-version.py` script) is recorded.
5757
The `save-versions.py` script does not change any tags or release version numbers.
5858

59-
6059
History
6160
--------
6261

0 commit comments

Comments
 (0)