mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Update script for backporting.
This commit is contained in:
parent
32b3e7946c
commit
1edf735e8d
@ -49,7 +49,7 @@ parser.add_argument('--token', type=str, required=True,
|
|||||||
help='token for Github access')
|
help='token for Github access')
|
||||||
parser.add_argument('--login', type=str,
|
parser.add_argument('--login', type=str,
|
||||||
help='filter authorship by login')
|
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')
|
help='try to automatically parse PR description and put labels')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -80,6 +80,8 @@ for i in reversed(range(len(stables))):
|
|||||||
|
|
||||||
members = set(github.get_members("ClickHouse", "ClickHouse"))
|
members = set(github.get_members("ClickHouse", "ClickHouse"))
|
||||||
def print_responsible(pull_request):
|
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:
|
if pull_request["author"]["login"] in members:
|
||||||
return colored(pull_request["author"]["login"], 'green')
|
return colored(pull_request["author"]["login"], 'green')
|
||||||
elif pull_request["mergedBy"]["login"] in members:
|
elif pull_request["mergedBy"]["login"] in members:
|
||||||
|
@ -10,6 +10,10 @@ class Description:
|
|||||||
'Performance Improvement': 'pr-performance',
|
'Performance Improvement': 'pr-performance',
|
||||||
# 'Backward Incompatible Change': doesn't match anything
|
# 'Backward Incompatible Change': doesn't match anything
|
||||||
'Build/Testing/Packaging Improvement': 'pr-build',
|
'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
|
# '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':
|
if stripped == 'I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en':
|
||||||
self.legal = True
|
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
|
next_category = True
|
||||||
|
|
||||||
if category in Description.MAP_CATEGORY_TO_LABEL:
|
if category in Description.MAP_CATEGORY_TO_LABEL:
|
||||||
self.label_name = Description.MAP_CATEGORY_TO_LABEL[category]
|
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)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class Query:
|
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:
|
while True:
|
||||||
import inspect
|
request = requests_retry_session().post('https://api.github.com/graphql', json={'query': query}, headers=headers)
|
||||||
caller = inspect.getouterframes(inspect.currentframe(), 2)[1][3]
|
if request.status_code == 200:
|
||||||
if caller not in self.api_costs.keys():
|
result = request.json()
|
||||||
self.api_costs[caller] = 0
|
if 'errors' in result:
|
||||||
self.api_costs[caller] += result['data']['rateLimit']['cost']
|
raise Exception(f'Errors occured: {result["errors"]}')
|
||||||
|
|
||||||
return result['data']
|
if not is_mutation:
|
||||||
else:
|
import inspect
|
||||||
import json
|
caller = inspect.getouterframes(inspect.currentframe(), 2)[1][3]
|
||||||
raise Exception(f'Query failed with code {request.status_code}:\n{json.dumps(request.json(), indent=4)}')
|
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)}')
|
||||||
|
Loading…
Reference in New Issue
Block a user