Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] runbot_merge: create controller to merge a commit #1054

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[ADD] runbot_merge: create controller to merge a commit
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 17, 2025
commit 2f1a9e718910d274e531f3268f44d5d4a3a73223
1 change: 1 addition & 0 deletions runbot_merge/controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from odoo.http import Controller, request, route, Response

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

Expand Down
39 changes: 39 additions & 0 deletions runbot_merge/controllers/misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- 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"):
"""Merge a specific commit hash in a repository

The commit_hash must be known by mergebot (in the git network)
Used for translation synchronisation from transifex
"""
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}