plugin merge request (mercurial): clean item_id for import (some chars are not accepted in name)
This commit is contained in:
parent
da71887397
commit
4127bcffd0
1 changed files with 3 additions and 2 deletions
|
|
@ -39,6 +39,7 @@ PLUGIN_INFO = {
|
|||
}
|
||||
|
||||
SHORT_DESC = D_(u"handle Mercurial repository")
|
||||
CLEAN_RE = re.compile(ur'[^\w -._]', flags=re.UNICODE)
|
||||
|
||||
|
||||
class MercurialProtocol(protocol.ProcessProtocol):
|
||||
|
|
@ -132,10 +133,10 @@ class MercurialHandler(object):
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue