diff --git a/runbot/models/build.py b/runbot/models/build.py index 2479396f..f4b0b09b 100644 --- a/runbot/models/build.py +++ b/runbot/models/build.py @@ -329,6 +329,8 @@ class BuildResult(models.Model): build_by_old_values = defaultdict(lambda: self.env['runbot.build']) for record in self: build_by_old_values[record.local_state] += record + if values['local_state'] == 'done': + self.env['runbot.commit.export'].search([('build_id', 'in', self.ids)]).unlink() local_result = values.get('local_result') for build in self: if local_result and local_result != self._get_worst_result([build.local_result, local_result]): # dont write ok on a warn/error build @@ -729,8 +731,6 @@ class BuildResult(models.Model): build._github_status() build._run_job() - if build.local_state == 'done': - self.env['runbot.commit.export'].search([('build_id', '=', build.id)]).unlink() def _run_job(self): # run job diff --git a/runbot/models/commit.py b/runbot/models/commit.py index cb12b378..e2e3d0d4 100644 --- a/runbot/models/commit.py +++ b/runbot/models/commit.py @@ -56,7 +56,8 @@ class Commit(models.Model): """Export a git repo into a sources""" # TODO add automated tests self.ensure_one() - self.env['runbot.commit.export'].create({'commit_id': self.id, 'build_id': build.id}) + if not self.env['runbot.commit.export'].search([('build_id', '=', build.id), ('commit_id', '=', self.id)]): + self.env['runbot.commit.export'].create({'commit_id': self.id, 'build_id': build.id}) export_path = self._source_path() if os.path.isdir(export_path):