diff --git a/conftest.py b/conftest.py index b043a48b..b17d2b09 100644 --- a/conftest.py +++ b/conftest.py @@ -326,6 +326,7 @@ class DbDict(dict): f.write(db) f.flush() os.fsync(f.fileno()) + subprocess.run(['psql', db, '-c', "UPDATE ir_cron SET nextcall = 'infinity'"]) return db diff --git a/runbot_merge/models/crons/cleanup_scratch_branches.py b/runbot_merge/models/crons/cleanup_scratch_branches.py index a5e041ce..cfe05f32 100644 --- a/runbot_merge/models/crons/cleanup_scratch_branches.py +++ b/runbot_merge/models/crons/cleanup_scratch_branches.py @@ -9,10 +9,11 @@ class BranchCleanup(models.TransientModel): _description = "cleans up scratch refs for deactivated branches" def _run(self): - deactivated = self.env['runbot_merge.branch'].search([ - ('active', '=', False), - ('write_date', '>=', self.env.context['lastcall']), - ]) + domain = [('active', '=', False)] + if lastcall := self.env.context['lastcall']: + domain.append(('write_date', '>=', lastcall)) + deactivated = self.env['runbot_merge.branch'].search(domain) + _logger.info( "deleting scratch (tmp and staging) refs for branches %s", ', '.join(b.name for b in deactivated)