未验证 提交 cf7b6a4f 编写于 作者: N Nikolai Kochetov 提交者: GitHub

Merge pull request #9685 from ClickHouse/backport-script-fixes

Update script for backporting.
......@@ -49,7 +49,7 @@ parser.add_argument('--token', type=str, required=True,
help='token for Github access')
parser.add_argument('--login', type=str,
help='filter authorship by login')
parser.add_argument('--auto-label', action='store_true', dest='autolabel',
parser.add_argument('--auto-label', action='store_true', dest='autolabel', default=True,
help='try to automatically parse PR description and put labels')
args = parser.parse_args()
......@@ -80,6 +80,8 @@ for i in reversed(range(len(stables))):
members = set(github.get_members("ClickHouse", "ClickHouse"))
def print_responsible(pull_request):
if "author" not in pull_request or pull_request["author"] is None:
return "No author"
if pull_request["author"]["login"] in members:
return colored(pull_request["author"]["login"], 'green')
elif pull_request["mergedBy"]["login"] in members:
......
......@@ -10,6 +10,10 @@ class Description:
'Performance Improvement': 'pr-performance',
# 'Backward Incompatible Change': doesn't match anything
'Build/Testing/Packaging Improvement': 'pr-build',
'Non-significant (changelog entry is not needed)': 'pr-non-significant',
'Non-significant (changelog entry is not required)': 'pr-non-significant',
'Non-significant': 'pr-non-significant',
'Documentation (changelog entry is not required)': 'pr-documentation',
# 'Other': doesn't match anything
}
......@@ -37,8 +41,20 @@ class Description:
if stripped == 'I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en':
self.legal = True
if stripped == 'Category (leave one):':
category_headers = (
'Category (leave one):',
'Changelog category (leave one):',
'Changelog category:',
'Category:'
)
if stripped in category_headers:
next_category = True
if category in Description.MAP_CATEGORY_TO_LABEL:
self.label_name = Description.MAP_CATEGORY_TO_LABEL[category]
else:
if not category:
print('Cannot find category in pr description')
else:
print('Unknown category: ' + category)
# -*- coding: utf-8 -*-
import requests
import time
class Query:
......@@ -394,20 +395,28 @@ class Query:
}}
}}
'''
request = requests_retry_session().post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
result = request.json()
if 'errors' in result:
raise Exception(f'Errors occured: {result["errors"]}')
if not is_mutation:
import inspect
caller = inspect.getouterframes(inspect.currentframe(), 2)[1][3]
if caller not in self.api_costs.keys():
self.api_costs[caller] = 0
self.api_costs[caller] += result['data']['rateLimit']['cost']
return result['data']
else:
import json
raise Exception(f'Query failed with code {request.status_code}:\n{json.dumps(request.json(), indent=4)}')
while True:
request = requests_retry_session().post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
result = request.json()
if 'errors' in result:
raise Exception(f'Errors occured: {result["errors"]}')
if not is_mutation:
import inspect
caller = inspect.getouterframes(inspect.currentframe(), 2)[1][3]
if caller not in self.api_costs.keys():
self.api_costs[caller] = 0
self.api_costs[caller] += result['data']['rateLimit']['cost']
return result['data']
else:
import json
resp = request.json()
if resp and len(resp) > 0 and resp[0] and 'type' in resp[0] and resp[0]['type'] == 'RATE_LIMITED':
print("API rate limit exceeded. Waiting for 1 second.")
time.sleep(1)
continue
raise Exception(f'Query failed with code {request.status_code}:\n{json.dumps(resp, indent=4)}')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册