[CHG] runbot_merge: move labels cron to triggered

Missed it during the previous pass, probably because it's in the
middle of `pull_requests.py`. It's a classic template for triggered
crons since the model is just a queue of actions for the cron.
This commit is contained in:
Xavier Morel 2024-10-22 10:50:09 +02:00
parent 640392dc20
commit 632763d390
3 changed files with 3 additions and 3 deletions

View File

@ -38,7 +38,7 @@
<field name="state">code</field>
<field name="code">model._send()</field>
<field name="interval_number">10</field>
<field name="interval_type">minutes</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False"/>
<field name="priority">70</field>

View File

@ -1758,6 +1758,8 @@ class Tagging(models.Model):
values['tags_remove'] = json.dumps(list(values['tags_remove']))
if not isinstance(values.get('tags_add', ''), str):
values['tags_add'] = json.dumps(list(values['tags_add']))
if values:
self.env.ref('runbot_merge.labels_cron')._trigger()
return super().create(values)
def _send(self):

View File

@ -149,7 +149,6 @@ def test_pseudo_version_tag(env, project, make_repo, setreviewers, config):
with repo:
repo.post_status('staging.master', 'success', 'ci')
env.run_crons() # should merge staging
env.run_crons('runbot_merge.labels_cron') # update labels
assert pr_id.state == 'merged'
assert pr.labels >= {'2.1'}
@ -170,6 +169,5 @@ def test_pseudo_version_tag(env, project, make_repo, setreviewers, config):
with repo:
repo.post_status('staging.master', 'success', 'ci')
env.run_crons() # should merge staging
env.run_crons('runbot_merge.labels_cron') # update labels
assert pr_id.state == 'merged'
assert pr.labels >= {'post-bonk'}