mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] forwardbot: reduce length of fw branch name
* shorten the postfix, forwardbot is now a bigram! * shorten the uniquifier: go from 5 to 3 bytes, and use urlsafe base64 that way we only have a 4-char uniquifier instead of 8 * while at it, fix deprecated calls to logging.warn (should be logging.warning) Fixes #226
This commit is contained in:
parent
d453943252
commit
036ae3a8ee
@ -39,7 +39,7 @@ class BatchQueue(models.Model, Queue):
|
||||
# only some prs of the batch have a parent, that's weird
|
||||
with_parent = batch.prs.filtered(lambda p: p.parent_id)
|
||||
if with_parent and with_parent != batch.prs:
|
||||
_logger.warn("Found a subset of batch %s (%s) with parents: %s, should probably investigate (normally either they're all parented or none are)", batch, batch.prs, with_parent)
|
||||
_logger.warning("Found a subset of batch %s (%s) with parents: %s, should probably investigate (normally either they're all parented or none are)", batch, batch.prs, with_parent)
|
||||
|
||||
newbatch = batch.prs._port_forward()
|
||||
if newbatch:
|
||||
|
@ -66,7 +66,7 @@ class Project(models.Model):
|
||||
'Authorization': 'token %s' % project.fp_github_token
|
||||
})
|
||||
if not (r0.ok and r1.ok):
|
||||
_logger.warn("Failed to fetch bot information for project %s: %s", project.name, (r0.text or r0.content) if not r0.ok else (r1.text or r1.content))
|
||||
_logger.warning("Failed to fetch bot information for project %s: %s", project.name, (r0.text or r0.content) if not r0.ok else (r1.text or r1.content))
|
||||
continue
|
||||
project.fp_github_name = r0.json()['login']
|
||||
project.fp_github_email = next((
|
||||
@ -424,7 +424,7 @@ class PullRequests(models.Model):
|
||||
|
||||
proj = self.mapped('target.project_id')
|
||||
if not proj.fp_github_token:
|
||||
_logger.warn(
|
||||
_logger.warning(
|
||||
"Can not forward-port %s#%s: no token on project %s",
|
||||
ref.repository.name, ref.number,
|
||||
proj.name
|
||||
@ -433,19 +433,19 @@ class PullRequests(models.Model):
|
||||
|
||||
notarget = [p.repository.name for p in self if not p.repository.fp_remote_target]
|
||||
if notarget:
|
||||
_logger.warn(
|
||||
_logger.warning(
|
||||
"Can not forward-port %s: repos %s don't have a remote configured",
|
||||
self, ', '.join(notarget)
|
||||
)
|
||||
return
|
||||
|
||||
# take only the branch bit
|
||||
new_branch = '%s-%s-%s-forwardport' % (
|
||||
new_branch = '%s-%s-%s-fw' % (
|
||||
target.name,
|
||||
base.refname,
|
||||
# avoid collisions between fp branches (labels can be reused
|
||||
# or conflict especially as we're chopping off the owner)
|
||||
base64.b32encode(os.urandom(5)).decode()
|
||||
base64.urlsafe_b64encode(os.urandom(3)).decode()
|
||||
)
|
||||
# TODO: send outputs to logging?
|
||||
conflicts = {}
|
||||
|
@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# target branch '-' source branch '-' base32 unique '-forwardport'
|
||||
import itertools
|
||||
import re
|
||||
|
||||
@ -8,7 +7,8 @@ MESSAGE_TEMPLATE = """{message}
|
||||
closes {repo}#{number}
|
||||
|
||||
{headers}Signed-off-by: {name} <{login}@users.noreply.github.com>"""
|
||||
REF_PATTERN = r'{target}-{source}-\w{{8}}-forwardport'
|
||||
# target branch '-' source branch '-' base64 unique '-fw'
|
||||
REF_PATTERN = r'{target}-{source}-[a-zA-Z0-9_-]{{4}}-fw'
|
||||
|
||||
class Commit:
|
||||
def __init__(self, message, *, author=None, committer=None, tree, reset=False):
|
||||
|
@ -89,7 +89,7 @@ class GH(object):
|
||||
if _is_json(r.response):
|
||||
body = r.response.json()
|
||||
if any(e.message == 'User is blocked' for e in (body.get('errors') or [])):
|
||||
_logger.warn("comment(%s:%s) failed: user likely blocked", self._repo, pr)
|
||||
_logger.warning("comment(%s:%s) failed: user likely blocked", self._repo, pr)
|
||||
return
|
||||
raise
|
||||
_logger.debug('comment(%s, %s, %s)', self._repo, pr, shorten(message))
|
||||
|
@ -415,7 +415,7 @@ class Branch(models.Model):
|
||||
i, len(WAIT_FOR_VISIBILITY)
|
||||
)
|
||||
break
|
||||
_logger.warn(
|
||||
_logger.warning(
|
||||
"[repo] updated %s:%s to %s: failed (at %d/%d)",
|
||||
r.name, refname, staging_head,
|
||||
i, len(WAIT_FOR_VISIBILITY)
|
||||
@ -1123,7 +1123,7 @@ class PullRequests(models.Model):
|
||||
"""
|
||||
split_batches = self.with_context(active_test=False).mapped('batch_ids').filtered('split_id')
|
||||
if len(split_batches) > 1:
|
||||
_logger.warn("Found a PR linked with more than one split batch: %s (%s)", self, split_batches)
|
||||
_logger.warning("Found a PR linked with more than one split batch: %s (%s)", self, split_batches)
|
||||
for b in split_batches:
|
||||
if len(b.split_id.batch_ids) == 1:
|
||||
# only the batch of this PR -> delete split
|
||||
|
Loading…
Reference in New Issue
Block a user