mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] runbot: avoid loosing hooks
In the same spirit of getting garanties that community is updated when enterprise is, force the hook time of dependencies in case it was lost.
This commit is contained in:
parent
f51a021dfe
commit
6bc666b5c3
@ -6,7 +6,7 @@
|
||||
'author': "Odoo SA",
|
||||
'website': "http://runbot.odoo.com",
|
||||
'category': 'Website',
|
||||
'version': '4.1',
|
||||
'version': '4.2',
|
||||
'depends': ['website', 'base'],
|
||||
'data': [
|
||||
'security/runbot_security.xml',
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import datetime
|
||||
import time
|
||||
import json
|
||||
|
||||
from odoo import http, tools
|
||||
@ -25,5 +25,7 @@ class RunbotHook(http.Controller):
|
||||
repo_id = repo.id
|
||||
|
||||
repo = request.env['runbot.repo'].sudo().browse([repo_id])
|
||||
repo.hook_time = datetime.datetime.now().strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
# force update of dependencies to in case a hook is lost
|
||||
(repo | repo.dependency_ids).write({'hook_time': time.time()})
|
||||
return ""
|
||||
|
@ -35,7 +35,7 @@ class runbot_repo(models.Model):
|
||||
('hook', 'Hook')],
|
||||
default='poll',
|
||||
string="Mode", required=True, help="hook: Wait for webhook on /runbot/hook/<id> i.e. github push event")
|
||||
hook_time = fields.Datetime('Last hook time')
|
||||
hook_time = fields.Float('Last hook time')
|
||||
get_ref_time = fields.Float('Last refs db update')
|
||||
duplicate_id = fields.Many2one('runbot.repo', 'Duplicate repo', help='Repository for finding duplicate builds')
|
||||
modules = fields.Char("Modules to install", help="Comma-separated list of modules to install and test.")
|
||||
@ -327,10 +327,10 @@ class runbot_repo(models.Model):
|
||||
fname_fetch_head = os.path.join(repo.path, 'FETCH_HEAD')
|
||||
if not force and os.path.isfile(fname_fetch_head):
|
||||
fetch_time = os.path.getmtime(fname_fetch_head)
|
||||
if repo.mode == 'hook' and (not repo.hook_time or dt2time(repo.hook_time) < fetch_time):
|
||||
if repo.mode == 'hook' and (not repo.hook_time or repo.hook_time < fetch_time):
|
||||
t0 = time.time()
|
||||
_logger.debug('repo %s skip hook fetch fetch_time: %ss ago hook_time: %ss ago',
|
||||
repo.name, int(t0 - fetch_time), int(t0 - dt2time(repo.hook_time)) if repo.hook_time else 'never')
|
||||
repo.name, int(t0 - fetch_time), int(t0 - repo.hook_time) if repo.hook_time else 'never')
|
||||
return
|
||||
|
||||
self._update_fetch_cmd()
|
||||
|
Loading…
Reference in New Issue
Block a user