mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX] runbot: ensure that commit date is always set
When exporting a commit, the commit date is used in the `tar` command to set the date of the exported folder. On the other hand it happens that a commit is not found in the database and should be quickly created on the fly. e.g.: with the `_get` method. In this case, if the commit needs to be exported later, the method fails and may break a runbot build. It happened with a custom python step.
This commit is contained in:
parent
ce47661bbc
commit
fef9ae9801
@ -34,6 +34,13 @@ class Commit(models.Model):
|
|||||||
dname = fields.Char('Display name', compute='_compute_dname')
|
dname = fields.Char('Display name', compute='_compute_dname')
|
||||||
rebase_on_id = fields.Many2one('runbot.commit', 'Rebase on commit')
|
rebase_on_id = fields.Many2one('runbot.commit', 'Rebase on commit')
|
||||||
|
|
||||||
|
@api.model_create_multi
|
||||||
|
def create(self, vals_list):
|
||||||
|
for vals in vals_list:
|
||||||
|
if 'date' not in vals:
|
||||||
|
vals['date'] = fields.Datetime.now()
|
||||||
|
return super().create(vals_list)
|
||||||
|
|
||||||
def _get(self, name, repo_id, vals=None, rebase_on_id=False):
|
def _get(self, name, repo_id, vals=None, rebase_on_id=False):
|
||||||
commit = self.search([('name', '=', name), ('repo_id', '=', repo_id), ('rebase_on_id', '=', rebase_on_id)])
|
commit = self.search([('name', '=', name), ('repo_id', '=', repo_id), ('rebase_on_id', '=', rebase_on_id)])
|
||||||
if not commit:
|
if not commit:
|
||||||
|
@ -6,6 +6,17 @@ from werkzeug.urls import url_parse
|
|||||||
from odoo.tests.common import HttpCase, new_test_user, tagged
|
from odoo.tests.common import HttpCase, new_test_user, tagged
|
||||||
from odoo.tools import mute_logger
|
from odoo.tools import mute_logger
|
||||||
|
|
||||||
|
from .common import RunbotCaseMinimalSetup
|
||||||
|
|
||||||
|
class TestCommitDate(RunbotCaseMinimalSetup):
|
||||||
|
|
||||||
|
def test_commit_has_date(self):
|
||||||
|
commit = self.Commit.create({
|
||||||
|
'name': 'caca00caca00ffffffffffffffffffffffffffff',
|
||||||
|
'repo_id': self.repo_server.id
|
||||||
|
})
|
||||||
|
|
||||||
|
self.assertNotEqual(commit.date, False, "A commit should always have a date")
|
||||||
|
|
||||||
@tagged('post_install', '-at_install')
|
@tagged('post_install', '-at_install')
|
||||||
class TestCommitStatus(HttpCase):
|
class TestCommitStatus(HttpCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user