Skip to content

Commit

Permalink
[IMP] runbot_merge: style fixes
Browse files Browse the repository at this point in the history
- replace manual token_urlsafe by actual token_urlsafe
- make conditional right side up and more readable
- replace match by fullmatch, should not change anything since we end
  with a greedy universal match but is slightly more explicit
  • Loading branch information
xmo-odoo committed Oct 22, 2024
1 parent d9e6d39 commit ed1f084
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions runbot_merge/models/batch.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from __future__ import annotations

import base64
import contextlib
import logging
import os
import re
import secrets
from collections import defaultdict
from collections.abc import Iterator

Expand Down Expand Up @@ -323,9 +321,7 @@ def _port_forward(self):
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.urlsafe_b64encode(os.urandom(3)).decode()
secrets.token_urlsafe(3),
)
conflicts = {}
for pr in prs:
Expand All @@ -352,11 +348,11 @@ def _port_forward(self):
for p in root | source
)

title, body = re.match(r'(?P<title>[^\n]+)\n*(?P<body>.*)', message, flags=re.DOTALL).groups()
title, body = re.fullmatch(r'(?P<title>[^\n]+)\n*(?P<body>.*)', message, flags=re.DOTALL).groups()
r = gh.post(f'https://api.github.com/repos/{pr.repository.name}/pulls', json={
'base': target.name,
'head': f'{owner}:{new_branch}',
'title': '[FW]' + (' ' if title[0] != '[' else '') + title,
'title': '[FW]' + ('' if title[0] == '[' else ' ') + title,
'body': body
})
if not r.ok:
Expand Down

0 comments on commit ed1f084

Please sign in to comment.