[calm - Cygwin server-side packaging maintenance script] branch master, updated. 20210110-4-g76b5a94
Jon TURNEY
jturney@sourceware.org
Mon Mar 15 16:05:53 GMT 2021
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=76b5a949c305e52380c3861cf4855e69ccd53929
commit 76b5a949c305e52380c3861cf4855e69ccd53929
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date: Sun Mar 14 19:43:48 2021 +0000
Drop testing with EOL-ed and no longer present python 3.4 from github action
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=30fb89cfc381589bc34412be3d8c150ea6eb10da
commit 30fb89cfc381589bc34412be3d8c150ea6eb10da
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date: Sun Mar 14 19:36:17 2021 +0000
Handle epoch (if present) in version comparison
Diff:
---
.github/workflows/calm.yaml | 2 +-
calm/version.py | 18 ++++++++++++++----
test/test_calm.py | 5 +++++
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/calm.yaml b/.github/workflows/calm.yaml
index bae70d4..5fce459 100644
--- a/.github/workflows/calm.yaml
+++ b/.github/workflows/calm.yaml
@@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: [3.4, 3.5, 3.6, 3.7, 3.8]
+ python-version: [3.5, 3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
diff --git a/calm/version.py b/calm/version.py
index 508260e..17f8d0e 100644
--- a/calm/version.py
+++ b/calm/version.py
@@ -43,20 +43,25 @@ class SetupVersion:
def __init__(self, version_string):
self._version_string = version_string
- # split version into [V, R], on the last '-', if any
- split = list(itertools.chain(version_string.rsplit('-', 1), ['']))[:2]
+ # split release on the last '-', if any (default '')
+ v, r = list(itertools.chain(version_string.rsplit('-', 1), ['']))[:2]
+
+ # split epoch, on the first ':', if any (default '0')
+ e, v = list(itertools.chain('0', v.split(':', 1)))[-2:]
+
+ split = [e, v, r]
# then split each part into numeric and alphabetic sequences
# non-alphanumeric separators are discarded
# numeric sequences have leading zeroes discarded
- for j, i in enumerate(['V', 'R']):
+ for j, i in enumerate(['E', 'V', 'R']):
sequences = re.finditer(r'(\d+|[a-zA-Z]+|[^a-zA-Z\d]+)', split[j])
sequences = [m for m in sequences if not re.match(r'[^a-zA-Z\d]+', m.group(1))]
sequences = [re.sub(r'^0+(\d)', r'\1', m.group(1), 1) for m in sequences]
setattr(self, '_' + i, sequences)
def __str__(self):
- return '%s (V=%s R=%s)' % (self._version_string, str(self._V), str(self._R))
+ return '%s (E=%s V=%s R=%s)' % (self._version_string, str(self._E), str(self._V), str(self._R))
def __lt__(self, other):
return self.__cmp__(other) == -1
@@ -65,6 +70,11 @@ class SetupVersion:
return self.__cmp__(other) == 0
def __cmp__(self, other):
+ # compare E
+ c = SetupVersion._compare(self._E, other._E)
+ if c != 0:
+ return c
+
# compare V
c = SetupVersion._compare(self._V, other._V)
if c != 0:
diff --git a/test/test_calm.py b/test/test_calm.py
index 4c24313..7ea9718 100755
--- a/test/test_calm.py
+++ b/test/test_calm.py
@@ -220,6 +220,11 @@ class CalmTest(unittest.TestCase):
["0.6.7+20150214+git3a710f9-1", "0.6.7-1", 1],
["15.8b-1", "15.8.0.1-2", -1],
["1.2rc1-1", "1.2.0-2", -1],
+ ["20090325-1", "1:5.6.0-1", -1],
+ ["0:20090325-1", "1:5.6.0-1", -1],
+ ["2:20090325-1", "1:5.6.0-1", 1],
+ ["2:1.0-1", "1:5.6.0-1", 1],
+ ["1.0-1", "0:1.0-1", 0],
# examples from https://fedoraproject.org/wiki/Archive:Tools/RPM/VersionComparison
["1.0010", "1.9", 1],
["1.05", "1.5", 0],
More information about the Cygwin-apps-cvs
mailing list