ReviewBot: break down sub-types of delete requests.
Their is very little overlap in the types of reviews one typically wants to perform on delete requests. Already all of the existing code will crash if a delete project request is reviewed.
This commit is contained in:
parent
628c1a107d
commit
d1b630b5da
29
ReviewBot.py
29
ReviewBot.py
@ -344,10 +344,7 @@ class ReviewBot(object):
|
||||
# Store in-case sub-classes need direct access to original values.
|
||||
self.action = a
|
||||
|
||||
fn = 'check_action_%s'%a.type
|
||||
if not hasattr(self, fn):
|
||||
fn = 'check_action__default'
|
||||
func = getattr(self, fn)
|
||||
func = getattr(self, self.action_method(a))
|
||||
ret = func(req, a)
|
||||
|
||||
# In the case of multiple actions take the "lowest" result where the
|
||||
@ -359,6 +356,30 @@ class ReviewBot(object):
|
||||
|
||||
return overall
|
||||
|
||||
def action_method(self, action):
|
||||
method_prefix = 'check_action'
|
||||
method_type = action.type
|
||||
method_suffix = None
|
||||
|
||||
if method_type == 'delete':
|
||||
method_suffix = 'project'
|
||||
if action.tgt_package is not None:
|
||||
method_suffix = 'package'
|
||||
elif action.tgt_repository is not None:
|
||||
method_suffix = 'repository'
|
||||
|
||||
if method_suffix:
|
||||
method = '_'.join([method_prefix, method_type, method_suffix])
|
||||
if hasattr(self, method):
|
||||
return method
|
||||
|
||||
method = '_'.join([method_prefix, method_type])
|
||||
if hasattr(self, method):
|
||||
return method
|
||||
|
||||
method_type = '_default'
|
||||
return '_'.join([method_prefix, method_type])
|
||||
|
||||
@staticmethod
|
||||
def _is_patchinfo(pkgname):
|
||||
return pkgname == 'patchinfo' or pkgname.startswith('patchinfo.')
|
||||
|
Loading…
x
Reference in New Issue
Block a user