mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[REM] toggle labels
Github labeling system may not be the best but this was not a good idea either, getting too much spam on pull requests
This commit is contained in:
parent
f13e0aabe3
commit
64a686aded
@ -43,10 +43,6 @@ _re_error = r'^(?:\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d{3} \d+ (?:ERROR|CRITICAL) )|
|
||||
_re_warning = r'^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d{3} \d+ WARNING '
|
||||
_re_job = re.compile('job_\d')
|
||||
|
||||
LABELS = {
|
||||
1: 'RDWIP',
|
||||
2: 'OE',
|
||||
}
|
||||
|
||||
#----------------------------------------------------------
|
||||
# RunBot helpers
|
||||
@ -1141,46 +1137,6 @@ class RunbotController(http.Controller):
|
||||
repo_id = registry['runbot.build'].force(cr, uid, [int(build_id)])
|
||||
return werkzeug.utils.redirect('/runbot/repo/%s' % repo_id)
|
||||
|
||||
@http.route(['/runbot/build/<build_id>/label/<label_id>'], type='http', auth="public", method='POST')
|
||||
def toggle_label(self, build_id=None, label_id=None, search=None, **post):
|
||||
registry, cr, uid, context = request.registry, request.cr, 1, request.context
|
||||
|
||||
build = registry['runbot.build'].browse(cr, uid, [int(build_id)])[0]
|
||||
issue_number = build.branch_id.name.split('/')
|
||||
if len(issue_number) == 3 and issue_number[0] == 'refs' and issue_number[1] == 'pull':
|
||||
issue_number = int(issue_number[2])
|
||||
else:
|
||||
# not a pull request
|
||||
return werkzeug.utils.redirect('/runbot/repo/%s' % build.repo_id.id)
|
||||
|
||||
label_id = int(label_id)
|
||||
if label_id not in LABELS:
|
||||
_logger.exception("unknown label")
|
||||
else:
|
||||
label_name = LABELS[label_id]
|
||||
found = False
|
||||
try:
|
||||
res = build.repo_id.github('/repos/:owner/:repo/issues/%s/labels' % issue_number)
|
||||
found = any([label for label in res if label['name'] == label_name])
|
||||
except Exception, e:
|
||||
_logger.exception("github error while fetching labels")
|
||||
|
||||
if found:
|
||||
# removing existing label
|
||||
try:
|
||||
build.repo_id.github('/repos/:owner/:repo/issues/%s/labels/%s' % (issue_number, label_name), delete=True)
|
||||
_logger.debug("removed github label %s for %s: %s", (label_name, issue_number))
|
||||
except Exception, e:
|
||||
_logger.exception("github error while removing label %s" % label_name)
|
||||
else:
|
||||
# adding the label
|
||||
try:
|
||||
build.repo_id.github('/repos/:owner/:repo/issues/%s/labels' % issue_number, [label_name])
|
||||
_logger.debug("added github label %s for %s: %s", (label_name, issue_number))
|
||||
except Exception, e:
|
||||
_logger.exception("github error while adding label %s" % label_name)
|
||||
return werkzeug.utils.redirect('/runbot/repo/%s' % build.repo_id.id)
|
||||
|
||||
@http.route([
|
||||
'/runbot/badge/<model("runbot.repo"):repo>/<branch>.svg',
|
||||
'/runbot/badge/<any(default,flat):theme>/<model("runbot.repo"):repo>/<branch>.svg',
|
||||
|
@ -270,9 +270,6 @@
|
||||
<li><a t-attf-href="https://{{repo.base}}/compare/{{br['branch'].branch_name}}">Compare <i class="fa fa-github"/></a></li>
|
||||
<!-- TODO branch.pull from -->
|
||||
<li class="divider"></li>
|
||||
<li><a t-attf-href="#" t-attf-onclick="$.post('/runbot/build/{{bu['id']}}/label/1')">Toggle RDWIP label</a></li>
|
||||
<li><a t-attf-href="#" t-attf-onclick="$.post('/runbot/build/{{bu['id']}}/label/2')">Toggle OE label</a></li>
|
||||
<li class="divider"></li>
|
||||
<li class="disabled"><a href="#">Runtime: <t t-esc="bu['job_time']"/>s</a></li>
|
||||
<li class="disabled"><a href="#">Port: <t t-esc="bu['port']"/></a></li>
|
||||
<li class="disabled"><a href="#">Age: <t t-esc="bu['job_age']"/></a></li>
|
||||
|
Loading…
Reference in New Issue
Block a user