Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support vX.X-conflicts tag in backport script. #9705

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 16 additions & 7 deletions utils/github/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

CHECK_MARK = colored('🗸', 'green')
CROSS_MARK = colored('🗙', 'red')
LABEL_MARK = colored('🏷', 'yellow')
BACKPORT_LABEL_MARK = colored('🏷', 'yellow')
CONFLICT_LABEL_MARK = colored('☁', 'yellow')
CLOCK_MARK = colored('↻', 'cyan')


Expand Down Expand Up @@ -126,12 +127,14 @@ def find_label():
# TODO: check backports.
if need_backporting:
re_vlabel = re.compile(r'^v\d+\.\d+$')
re_vlabel_conflicts = re.compile(r'^v\d+\.\d+-conflicts$')

print('\nPull-requests need to be backported:')
for pull_request in reversed(sorted(need_backporting, key=lambda x: x['number'])):
targets = [] # use common list for consistent order in output
good = set()
labeled = set()
backport_labeled = set()
conflict_labeled = set()
wait = set()

for stable in stables:
Expand All @@ -143,7 +146,10 @@ def find_label():
for label in github.get_labels(pull_request):
if re_vlabel.match(label['name']):
if f'v{stable[0]}' == label['name']:
labeled.add(stable[0])
backport_labeled.add(stable[0])
if re_vlabel_conflicts.match(label['name']):
if f'v{stable[0]}-conflicts' == label['name']:
conflict_labeled.add(stable[0])

for event in github.get_timeline(pull_request):
if(event['isCrossRepository'] or
Expand All @@ -165,16 +171,18 @@ def find_label():
wait.add(event['source']['baseRefName'])

# print pull-request's status
if len(good) + len(labeled) == len(targets):
if len(good) + len(backport_labeled) + len(conflict_labeled) == len(targets):
print(f'{CHECK_MARK}', end=' ')
else:
print(f'{CROSS_MARK}', end=' ')
print(f'{pull_request["number"]}', end=':')
for target in targets:
if target in good:
print(f'\t{CHECK_MARK} {target}', end='')
elif target in labeled:
print(f'\t{LABEL_MARK} {target}', end='')
elif target in backport_labeled:
print(f'\t{BACKPORT_LABEL_MARK} {target}', end='')
elif target in conflict_labeled:
print(f'\t{CONFLICT_LABEL_MARK} {target}', end='')
elif target in wait:
print(f'\t{CLOCK_MARK} {target}', end='')
else:
Expand All @@ -185,7 +193,8 @@ def find_label():
print('\nLegend:')
print(f'{CHECK_MARK} - good')
print(f'{CROSS_MARK} - bad')
print(f'{LABEL_MARK} - backport is detected via label')
print(f'{BACKPORT_LABEL_MARK} - backport is detected via label')
print(f'{CONFLICT_LABEL_MARK} - backport conflict is detected via label')
print(f'{CLOCK_MARK} - backport is waiting to merge')

# print API costs
Expand Down