[FIX] runbot_merge: don't warn on unrecognized commands

This is a regression due to the implementation details of
odoo/runbot#376: previously _parse_command would only yield the
commands it had specifically recognised (from a whitelist).

22e18e752b simplified the implementation
and (for convenience when adding new commands) now passes through any
command to the executor instead of skipping the unknown one.

But I forgot to update the executor to ignore unknown commands, so it
treats them as *failed* (since the success flag doesn't get set) and
assumes it's an ACL issue, so notifies the user that they can't do the
thing they never really asked for.

Add an end-case which skips the feedback bit for unrecognized
commands, which restores the old behavior.

Fixes #390
This commit is contained in:
Xavier Morel 2020-07-22 11:56:33 +02:00 committed by xmo-odoo
parent a564723fd8
commit 36026f46e4
3 changed files with 21 additions and 2 deletions

View File

@ -950,7 +950,10 @@ class PullRequests(models.Model):
c.create({'sha': self.head, 'statuses': '{}'})
ok = True
else:
msg = "You are not allowed to do that."
msg = f"You are not allowed to override this status."
else:
# ignore unknown commands
continue
_logger.info(
"%s %s(%s) on %s by %s (%s)",

View File

@ -2857,6 +2857,22 @@ class TestRecognizeCommands:
prx.post_comment('%shansen r+' % indent, config['role_reviewer']['token'])
assert pr.state == 'approved'
def test_unknown_commands(self, repo, env, config, users):
with repo:
m = repo.make_commit(None, 'initial', None, tree={'m': 'm'})
repo.make_ref('heads/master', m)
c = repo.make_commit(m, 'first', None, tree={'m': 'c'})
pr = repo.make_pr(title='title', body=None, target='master', head=c)
pr.post_comment("hansen do the thing", config['role_reviewer']['token'])
pr.post_comment('hansen @bobby-b r+ :+1:', config['role_reviewer']['token'])
env.run_crons()
assert pr.comments == [
(users['reviewer'], "hansen do the thing"),
(users['reviewer'], "hansen @bobby-b r+ :+1:"),
]
class TestRMinus:
def test_rminus_approved(self, repo, env, config):
""" approved -> r- -> opened

View File

@ -79,7 +79,7 @@ def test_override(env, project, make_repo, users, setreviewers, config):
assert comments == [
(users['reviewer'], 'hansen r+'),
(users['reviewer'], 'hansen override=l/int'),
(users['user'], "I'm sorry, @{}. You are not allowed to do that.".format(users['reviewer'])),
(users['user'], "I'm sorry, @{}. You are not allowed to override this status.".format(users['reviewer'])),
(users['other'], "hansen override=l/int"),
]
assert pr_id.statuses == '{}'