mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
Update scripts (#12726)
This commit is contained in:
parent
79a7c9c3f0
commit
1e10ce6bcf
@ -12,7 +12,7 @@ import sys
|
||||
|
||||
class Backport:
|
||||
def __init__(self, token, owner, name, team):
|
||||
self._gh = RemoteRepo(token, owner=owner, name=name, team=team, max_page_size=30)
|
||||
self._gh = RemoteRepo(token, owner=owner, name=name, team=team, max_page_size=30, min_page_size=7)
|
||||
self._token = token
|
||||
self.default_branch_name = self._gh.default_branch
|
||||
self.ssh_url = self._gh.ssh_url
|
||||
@ -39,12 +39,16 @@ class Backport:
|
||||
|
||||
RE_MUST_BACKPORT = re.compile(r'^v(\d+\.\d+)-must-backport$')
|
||||
RE_NO_BACKPORT = re.compile(r'^v(\d+\.\d+)-no-backport$')
|
||||
RE_BACKPORTED = re.compile(r'^v(\d+\.\d+)-backported$')
|
||||
|
||||
# pull-requests are sorted by ancestry from the least recent.
|
||||
for pr in prs:
|
||||
while repo.comparator(branches[-1][1]) >= repo.comparator(pr['mergeCommit']['oid']):
|
||||
logging.info("PR #{} is already inside {}. Dropping this branch for futher PRs".format(pr['number'], branches[-1][0]))
|
||||
branches.pop()
|
||||
|
||||
logging.info("Processing PR #{}".format(pr['number']))
|
||||
|
||||
assert len(branches)
|
||||
|
||||
branch_set = set([branch[0] for branch in branches])
|
||||
@ -65,14 +69,19 @@ class Backport:
|
||||
if label['name'] == 'pr-no-backport' and pr['number'] in backport_map:
|
||||
del backport_map[pr['number']]
|
||||
break
|
||||
m = RE_NO_BACKPORT.match(label['name'])
|
||||
if m and pr['number'] in backport_map and m.group(1) in backport_map[pr['number']]:
|
||||
backport_map[pr['number']].remove(m.group(1))
|
||||
m1 = RE_NO_BACKPORT.match(label['name'])
|
||||
m2 = RE_BACKPORTED.match(label['name'])
|
||||
if m1 and pr['number'] in backport_map and m1.group(1) in backport_map[pr['number']]:
|
||||
backport_map[pr['number']].remove(m1.group(1))
|
||||
logging.info('\tskipping %s because of forced no-backport', m1.group(1))
|
||||
elif m2 and pr['number'] in backport_map and m2.group(1) in backport_map[pr['number']]:
|
||||
backport_map[pr['number']].remove(m2.group(1))
|
||||
logging.info('\tskipping %s because it\'s already backported manually', m2.group(1))
|
||||
|
||||
for pr, branches in backport_map.items():
|
||||
logging.info('PR #%s needs to be backported to:', pr)
|
||||
for branch in branches:
|
||||
logging.info('\t%s %s', branch, run_cherrypick(self._token, pr, branch))
|
||||
logging.info('\t%s, and the status is: %s', branch, run_cherrypick(self._token, pr, branch))
|
||||
|
||||
# print API costs
|
||||
logging.info('\nGitHub API total costs per query:')
|
||||
|
@ -35,7 +35,9 @@ class CherryPick:
|
||||
MERGED = 'backported'
|
||||
|
||||
def _run(self, args):
|
||||
logging.info(subprocess.check_output(args))
|
||||
out = subprocess.check_output(args).rstrip()
|
||||
logging.debug(out)
|
||||
return out
|
||||
|
||||
def __init__(self, token, owner, name, team, pr_number, target_branch):
|
||||
self._gh = RemoteRepo(token, owner=owner, name=name, team=team)
|
||||
@ -117,8 +119,8 @@ class CherryPick:
|
||||
|
||||
self._run(git_prefix + ['checkout', '-f', self.backport_branch])
|
||||
self._run(git_prefix + ['pull', '--ff-only', 'origin', self.backport_branch])
|
||||
self._run(git_prefix + ['reset', '--soft', self._run(git_prefix + ['merge-base', self.target_branch, self.backport_branch])])
|
||||
self._run(git_prefix + ['commit', '-a', '-m', pr_title])
|
||||
self._run(git_prefix + ['reset', '--soft', self._run(git_prefix + ['merge-base', 'origin/' + self.target_branch, self.backport_branch])])
|
||||
self._run(git_prefix + ['commit', '-a', '--allow-empty', '-m', pr_title])
|
||||
self._run(git_prefix + ['push', '-f', 'origin', '{branch}:{branch}'.format(branch=self.backport_branch)])
|
||||
|
||||
pr = self._gh.create_pull_request(source=self.backport_branch, target=self.target_branch, title=pr_title,
|
||||
|
Loading…
Reference in New Issue
Block a user