[IMP] forwardport: error message when trying to r+ via fwbot

Initial thinking was to remove the check entirely and leave it to the
mergebot, but the lack of error reporting / forwarding means while
technically correct it would probably be somewhat difficult to grok.

Instead, improve the error reporting:

* add a dedicated message when trying to r+ via fwbot on a non-fw
  PR (note: maybe the fwbot should not care? and just send it as-is
  to the mergebot in that case?)
* clarify the ACL error
* post both message as the forwardbot rather than the mergebot

Also add a missing token note for the feedback from the forwardport
limit.

fix #469
This commit is contained in:
Xavier Morel 2021-07-27 15:23:34 +02:00 committed by xmo-odoo
parent 6b1f698c23
commit 8178b64c01

View File

@ -317,11 +317,24 @@ class PullRequests(models.Model):
tokens = itertools.chain(['to', self.target.name], tokens)
if token in ('r+', 'review+'):
if not self.source_id:
Feedback.create({
'repository': self.repository.id,
'pull_request': self.number,
'message': "I'm sorry, @{}. I can only do this on forward-port PRs and this ain't one.".format(login),
'token_field': 'fp_github_token',
})
continue
if not self.source_id._pr_acl(author).is_reviewer:
Feedback.create({
'repository': self.repository.id,
'pull_request': self.number,
'message': "I'm sorry, @{}. You can't review+.".format(login),
'message': "I'm sorry, @{}. You can't review this PR: "
"you need to be a reviewer on {}.".format(
login,
self.source_id.display_name
),
'token_field': 'fp_github_token',
})
continue
merge_bot = self.repository.project_id.github_prefix
@ -341,6 +354,7 @@ class PullRequests(models.Model):
'repository': self.repository.id,
'pull_request': self.number,
'message': "I'm sorry, @{}. You can't set a forward-port limit.".format(login),
'token_field': 'fp_github_token',
})
continue
if not limit: