plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
if "update" is set, former patches data can be used, so it's not mandatory to specify a repository. In this case, empty string may be used as repository.
This commit is contained in:
parent
6af707e529
commit
3c30ecd118
1 changed files with 36 additions and 30 deletions
|
|
@ -206,42 +206,48 @@ class MergeRequests(object):
|
|||
node = NS_MERGE_REQUESTS
|
||||
if values is None:
|
||||
values = {}
|
||||
update = extra.get('update', False)
|
||||
if not repository and not update:
|
||||
# in case of update, we may re-user former patches data
|
||||
# so repository is not mandatory
|
||||
raise exceptions.DataError(_(u"repository must be specified"))
|
||||
|
||||
if FIELD_DATA in values:
|
||||
raise exceptions.DataError(_(u"{field} is set by backend, you must not set it in frontend").format(
|
||||
field = FIELD_DATA))
|
||||
|
||||
if method == u'auto':
|
||||
for name in self._handlers_list:
|
||||
handler = self._handlers[name].handler
|
||||
can_handle = yield handler.check(repository)
|
||||
if can_handle:
|
||||
log.info(_(u"{name} handler will be used").format(name=name))
|
||||
break
|
||||
if repository:
|
||||
if method == u'auto':
|
||||
for name in self._handlers_list:
|
||||
handler = self._handlers[name].handler
|
||||
can_handle = yield handler.check(repository)
|
||||
if can_handle:
|
||||
log.info(_(u"{name} handler will be used").format(name=name))
|
||||
break
|
||||
else:
|
||||
log.warning(_(u"repository {path} can't be handled by any installed handler").format(
|
||||
path = repository))
|
||||
raise exceptions.NotFound(_(u"no handler for this repository has been found"))
|
||||
else:
|
||||
log.warning(_(u"repository {path} can't be handled by any installed handler").format(
|
||||
path = repository))
|
||||
raise exceptions.NotFound(_(u"no handler for this repository has been found"))
|
||||
else:
|
||||
try:
|
||||
handler = self._handlers[name].handler
|
||||
except KeyError:
|
||||
raise exceptions.NotFound(_(u"No handler of this name found"))
|
||||
try:
|
||||
handler = self._handlers[name].handler
|
||||
except KeyError:
|
||||
raise exceptions.NotFound(_(u"No handler of this name found"))
|
||||
|
||||
data = yield handler.export(repository)
|
||||
if not data.strip():
|
||||
raise exceptions.DataError(_(u'export data is empty, do you have any change to send?'))
|
||||
data = yield handler.export(repository)
|
||||
if not data.strip():
|
||||
raise exceptions.DataError(_(u'export data is empty, do you have any change to send?'))
|
||||
|
||||
if not values.get(u'title') or not values.get(u'body'):
|
||||
patches = yield handler.parse(data, values.get(FIELD_DATA_TYPE))
|
||||
commits_msg = patches[-1][self.META_COMMIT_MSG]
|
||||
msg_lines = commits_msg.splitlines()
|
||||
if not values.get(u'title'):
|
||||
values[u'title'] = msg_lines[0]
|
||||
if not values.get(u'body'):
|
||||
values[u'body'] = u'\n'.join(msg_lines[1:])
|
||||
if not values.get(u'title') or not values.get(u'body'):
|
||||
patches = yield handler.parse(data, values.get(FIELD_DATA_TYPE))
|
||||
commits_msg = patches[-1][self.META_COMMIT_MSG]
|
||||
msg_lines = commits_msg.splitlines()
|
||||
if not values.get(u'title'):
|
||||
values[u'title'] = msg_lines[0]
|
||||
if not values.get(u'body'):
|
||||
values[u'body'] = u'\n'.join(msg_lines[1:])
|
||||
|
||||
values[FIELD_DATA] = data
|
||||
values[FIELD_DATA] = data
|
||||
|
||||
item_id = yield self._t.set(client, service, node, values, schema, item_id, extra, deserialise, form_ns=NS_MERGE_REQUESTS)
|
||||
defer.returnValue(item_id)
|
||||
|
|
|
|||
Loading…
Reference in a new issue