Changeset - e68c0cd1647d
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2020-02-04 03:07:44
mads@kiilerich.com
Grafted from: d0f213273ba4
pull-request: refactor iteration version bump

Avoid relying on exceptions thrown when re.match fails ... and thus please
pytype and make the code better.
1 file changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/model/pull_request.py
Show inline comments
 
@@ -359,17 +359,17 @@ class CreatePullRequestIterationAction(o
 
            else:
 
                infos.append(_('This iteration is based on another %s revision and there is no simple diff.') % other_ref_name)
 
        else:
 
            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
 
        descriptions = description.replace('\r\n', '\n').split('\n-- \n', 1)
 
        description = descriptions[0].strip() + '\n\n-- \n' + '\n'.join(infos)
 
        if len(descriptions) > 1:
0 comments (0 inline, 0 general)