changeset 2623:49533de4540b

plugin merge request (mercurial): clean item_id for import (some chars are not accepted in name)
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 07:51:29 +0200
parents 8fb99ed47db4
children 56f94936df1e
files sat/plugins/plugin_merge_req_mercurial.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_merge_req_mercurial.py	Wed Jun 27 07:50:35 2018 +0200
+++ b/sat/plugins/plugin_merge_req_mercurial.py	Wed Jun 27 07:51:29 2018 +0200
@@ -39,6 +39,7 @@
 }
 
 SHORT_DESC = D_(u"handle Mercurial repository")
+CLEAN_RE = re.compile(ur'[^\w -._]', flags=re.UNICODE)
 
 
 class MercurialProtocol(protocol.ProcessProtocol):
@@ -132,10 +133,10 @@
         parsed_data = self.parse(data)
         try:
             parsed_name = parsed_data[0][u'commit_msg'].split(u'\n')[0]
-            parsed_name = re.sub(ur'[^\w -.:]', u'', parsed_name, flags=re.UNICODE)[:40]
+            parsed_name = CLEAN_RE.sub(u'', parsed_name)[:40]
         except Exception:
             parsed_name = u''
-        name = u'mr_{item_id}_{parsed_name}'.format(item_id=item_id,
+        name = u'mr_{item_id}_{parsed_name}'.format(item_id=CLEAN_RE.sub(u'', item_id),
                                                     parsed_name=parsed_name)
         return MercurialProtocol.run(repository, 'qimport', '-g', '--name', name,
                                      '--encoding=utf-8', '-', stdin=data)