public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jon TURNEY <jturney@sourceware.org>
To: cygwin-apps-cvs@sourceware.org
Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20210110-4-g76b5a94
Date: Mon, 15 Mar 2021 16:05:53 +0000 (GMT)	[thread overview]
Message-ID: <20210315160553.304793858C27@sourceware.org> (raw)




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],



                 reply	other threads:[~2021-03-15 16:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210315160553.304793858C27@sourceware.org \
    --to=jturney@sourceware.org \
    --cc=cygwin-apps-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).