Skip to content

Commit

Permalink
[ADD] runbot_merge: create controller to merge a commit
Browse files Browse the repository at this point in the history
This used to be done in RPC but the goal is to be able to call this from
another server and not rely on a user account.
  • Loading branch information
mart-e committed Feb 13, 2025
1 parent 0594c71 commit d7b6f2c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions runbot_merge/controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from odoo.http import Controller, request, route

from . import dashboard
from . import misc
from . import reviewer_provisioning
from .. import utils, github

Expand Down
34 changes: 34 additions & 0 deletions runbot_merge/controllers/misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

from odoo.http import Controller, request, route

try:
from odoo.addons.saas_worker.util import from_role
except ImportError:
def from_role(*_, **__):
return lambda _: None

class MergebotController(Controller):

@from_role('tx', signed=True)
@route('/i18n/merge_commit', type='json', auth='public')
def merge_commit(self, commit_hash, repository, branch, project="RD"):
repository_id = request.env["runbot_merge.repository"].sudo().search([
("name", "=", repository)
])
if not repository_id:
return {"error": "Repository %r not found" % repository}

target = request.env["runbot_merge.branch"].sudo().search([
("name", "=", branch),
("project_id", "=", project)
])
if not target:
return {"error": "Target branch %s:%s not found" % (branch, target)}

patch = request.env["runbot_merge.patch"].sudo().create({
"repository": repository_id.id,
"target": target.id,
"commit": commit_hash
})
return {"patch": patch.id}

0 comments on commit d7b6f2c

Please sign in to comment.