mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +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
|
# only some prs of the batch have a parent, that's weird
|
||||||
with_parent = batch.prs.filtered(lambda p: p.parent_id)
|
with_parent = batch.prs.filtered(lambda p: p.parent_id)
|
||||||
if with_parent and with_parent != batch.prs:
|
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()
|
newbatch = batch.prs._port_forward()
|
||||||
if newbatch:
|
if newbatch:
|
||||||
|
@ -66,7 +66,7 @@ class Project(models.Model):
|
|||||||
'Authorization': 'token %s' % project.fp_github_token
|
'Authorization': 'token %s' % project.fp_github_token
|
||||||
})
|
})
|
||||||
if not (r0.ok and r1.ok):
|
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
|
continue
|
||||||
project.fp_github_name = r0.json()['login']
|
project.fp_github_name = r0.json()['login']
|
||||||
project.fp_github_email = next((
|
project.fp_github_email = next((
|
||||||
@ -424,7 +424,7 @@ class PullRequests(models.Model):
|
|||||||
|
|
||||||
proj = self.mapped('target.project_id')
|
proj = self.mapped('target.project_id')
|
||||||
if not proj.fp_github_token:
|
if not proj.fp_github_token:
|
||||||
_logger.warn(
|
_logger.warning(
|
||||||
"Can not forward-port %s#%s: no token on project %s",
|
"Can not forward-port %s#%s: no token on project %s",
|
||||||
ref.repository.name, ref.number,
|
ref.repository.name, ref.number,
|
||||||
proj.name
|
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]
|
notarget = [p.repository.name for p in self if not p.repository.fp_remote_target]
|
||||||
if notarget:
|
if notarget:
|
||||||
_logger.warn(
|
_logger.warning(
|
||||||
"Can not forward-port %s: repos %s don't have a remote configured",
|
"Can not forward-port %s: repos %s don't have a remote configured",
|
||||||
self, ', '.join(notarget)
|
self, ', '.join(notarget)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
# take only the branch bit
|
# take only the branch bit
|
||||||
new_branch = '%s-%s-%s-forwardport' % (
|
new_branch = '%s-%s-%s-fw' % (
|
||||||
target.name,
|
target.name,
|
||||||
base.refname,
|
base.refname,
|
||||||
# avoid collisions between fp branches (labels can be reused
|
# avoid collisions between fp branches (labels can be reused
|
||||||
# or conflict especially as we're chopping off the owner)
|
# 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?
|
# TODO: send outputs to logging?
|
||||||
conflicts = {}
|
conflicts = {}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# target branch '-' source branch '-' base32 unique '-forwardport'
|
|
||||||
import itertools
|
import itertools
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -8,7 +7,8 @@ MESSAGE_TEMPLATE = """{message}
|
|||||||
closes {repo}#{number}
|
closes {repo}#{number}
|
||||||
|
|
||||||
{headers}Signed-off-by: {name} <{login}@users.noreply.github.com>"""
|
{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:
|
class Commit:
|
||||||
def __init__(self, message, *, author=None, committer=None, tree, reset=False):
|
def __init__(self, message, *, author=None, committer=None, tree, reset=False):
|
||||||
|
@ -89,7 +89,7 @@ class GH(object):
|
|||||||
if _is_json(r.response):
|
if _is_json(r.response):
|
||||||
body = r.response.json()
|
body = r.response.json()
|
||||||
if any(e.message == 'User is blocked' for e in (body.get('errors') or [])):
|
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
|
return
|
||||||
raise
|
raise
|
||||||
_logger.debug('comment(%s, %s, %s)', self._repo, pr, shorten(message))
|
_logger.debug('comment(%s, %s, %s)', self._repo, pr, shorten(message))
|
||||||
|
@ -415,7 +415,7 @@ class Branch(models.Model):
|
|||||||
i, len(WAIT_FOR_VISIBILITY)
|
i, len(WAIT_FOR_VISIBILITY)
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
_logger.warn(
|
_logger.warning(
|
||||||
"[repo] updated %s:%s to %s: failed (at %d/%d)",
|
"[repo] updated %s:%s to %s: failed (at %d/%d)",
|
||||||
r.name, refname, staging_head,
|
r.name, refname, staging_head,
|
||||||
i, len(WAIT_FOR_VISIBILITY)
|
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')
|
split_batches = self.with_context(active_test=False).mapped('batch_ids').filtered('split_id')
|
||||||
if len(split_batches) > 1:
|
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:
|
for b in split_batches:
|
||||||
if len(b.split_id.batch_ids) == 1:
|
if len(b.split_id.batch_ids) == 1:
|
||||||
# only the batch of this PR -> delete split
|
# only the batch of this PR -> delete split
|
||||||
|
Loading…
Reference in New Issue
Block a user