diff sat/plugins/plugin_merge_req_mercurial.py @ 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 2f75830a8228
children 163aab916bcf
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)