mirror of
https://github.com/odoo/runbot.git
synced 2025-03-26 04:45:52 +07:00

Before this change, a CI override would have to be replicated on most / all forward-ports of the base PR. This was intentional to see how it would shake out, the answer being that it's rather annoying. Also add a `statuses_full` computed field on PRs for the aggregate status: the existing `statuses` field is just a copy of the commit statuses which I didn't remember I kept free of the overrides so the commit statuses could be displayed "as-is" in the backend (the overrides are displayed separately). And while at it fix the PR dashboard to use that new field: that was basically the intention but then I went on to use the "wrong" field hence #433. Mebbe the UI part should be displayed using a computed M2M (?) as a table or as tags instead? This m2m could indicate whether the status is an override or an "intrinsic" status. Also removed some dead code: * leftover from the removed tagging feature (removed the tag manipulation but forgot some of the setup / computations) * unused local variables * an empty skipped test case Fixes #439. Fixes #433.
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
import json
|
|
|
|
import werkzeug.exceptions
|
|
|
|
from odoo.http import Controller, route, request
|
|
|
|
LIMIT = 20
|
|
class MergebotDashboard(Controller):
|
|
@route('/runbot_merge', auth="public", type="http", website=True)
|
|
def dashboard(self):
|
|
return request.render('runbot_merge.dashboard', {
|
|
'projects': request.env['runbot_merge.project'].with_context(active_test=False).sudo().search([]),
|
|
})
|
|
|
|
@route('/runbot_merge/<int:branch_id>', auth='public', type='http', website=True)
|
|
def stagings(self, branch_id, until=None):
|
|
stagings = request.env['runbot_merge.stagings'].with_context(active_test=False).sudo().search([
|
|
('target', '=', branch_id),
|
|
('staged_at', '<=', until) if until else (True, '=', True),
|
|
], order='staged_at desc', limit=LIMIT+1)
|
|
|
|
return request.render('runbot_merge.branch_stagings', {
|
|
'branch': request.env['runbot_merge.branch'].browse(branch_id).sudo(),
|
|
'stagings': stagings[:LIMIT],
|
|
'next': stagings[-1].staged_at if len(stagings) > LIMIT else None,
|
|
})
|
|
|
|
@route('/<org>/<repo>/pull/<int(min=1):pr>', auth='public', type='http', website=True)
|
|
def pr(self, org, repo, pr):
|
|
pr_id = request.env['runbot_merge.pull_requests'].sudo().search([
|
|
('repository.name', '=', f'{org}/{repo}'),
|
|
('number', '=', int(pr)),
|
|
])
|
|
if not pr_id:
|
|
raise werkzeug.exceptions.NotFound()
|
|
if not pr_id.repository.group_id <= request.env.user.groups_id:
|
|
raise werkzeug.exceptions.NotFound()
|
|
|
|
st = {}
|
|
if pr_id.statuses:
|
|
# normalise `statuses` to map to a dict
|
|
st = {
|
|
k: {'state': v} if isinstance(v, str) else v
|
|
for k, v in json.loads(pr_id.statuses_full).items()
|
|
}
|
|
return request.render('runbot_merge.view_pull_request', {
|
|
'pr': pr_id,
|
|
'merged_head': json.loads(pr_id.commits_map).get(''),
|
|
'statuses': st
|
|
})
|