Update script for backporting.

This commit is contained in:
Nikolai Kochetov 2020-03-16 18:27:07 +03:00
parent 32b3e7946c
commit 1edf735e8d
3 changed files with 44 additions and 17 deletions

View File

@ -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:

View File

@ -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)

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import requests
import time
class Query:
@ -394,6 +395,8 @@ class Query:
}}
}}
'''
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()
@ -410,4 +413,10 @@ class Query:
return result['data']
else:
import json
raise Exception(f'Query failed with code {request.status_code}:\n{json.dumps(request.json(), indent=4)}')
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)}')