changeset 8169:e68c0cd1647d

pull-request: refactor iteration version bump Avoid relying on exceptions thrown when re.match fails ... and thus please pytype and make the code better.
author Mads Kiilerich <mads@kiilerich.com>
date Tue, 04 Feb 2020 03:07:44 +0100
parents 7d5dfe117d0f
children 6db4784809cb
files kallithea/model/pull_request.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/model/pull_request.py	Tue Feb 04 02:58:53 2020 +0100
+++ b/kallithea/model/pull_request.py	Tue Feb 04 03:07:44 2020 +0100
@@ -362,11 +362,11 @@
             infos.append(_('No changes found on %s %s since previous iteration.') % (org_ref_type, org_ref_name))
             # TODO: fail?
 
-        try:
-            title, old_v = re.match(r'(.*)\(v(\d+)\)\s*$', title).groups()
-            v = int(old_v) + 1
-        except (AttributeError, ValueError):
-            v = 2
+        v = 2
+        m = re.match(r'(.*)\(v(\d+)\)\s*$', title)
+        if m is not None:
+            title = m.group(1)
+            v = int(m.group(2)) + 1
         self.create_action.title = '%s (v%s)' % (title.strip(), v)
 
         # using a mail-like separator, insert new iteration info in description with latest first