tools: Make the "Allow commits" error more obnoxious.

Add ANSI codes and emoji so that the error stands out in the pipeline
output. Clarify the text.
This commit is contained in:
Gerald Combs 2020-09-03 17:47:38 -07:00 committed by AndersBroman
parent c2b69f4e9b
commit fd075df3f8
1 changed files with 10 additions and 7 deletions

View File

@ -171,6 +171,12 @@ def verify_merge_request():
gitlab_api_pfx = "https://gitlab.com/api/v4"
# gitlab.com/wireshark/wireshark = 7898047
project_id = os.getenv('CI_MERGE_REQUEST_PROJECT_ID')
ansi_csi = '\x1b['
ansi_codes = {
'black_white': ansi_csi + '30;47m',
'bold_red': ansi_csi + '31;1m', # gitlab-runner errors
'reset': ansi_csi + '0m'
}
m_r_iid = os.getenv('CI_MERGE_REQUEST_IID')
if project_id is None or m_r_iid is None:
print("This doesn't appear to be a merge request. CI_MERGE_REQUEST_PROJECT_ID={}, CI_MERGE_REQUEST_IID={}".format(project_id, m_r_iid))
@ -186,13 +192,10 @@ def verify_merge_request():
try:
if not m_r_attrs['allow_collaboration']:
print('''\
ERROR: Please make sure the setting
Allow commits from members who can merge to the target branch
is checked in your merge request so that maintainers can rebase your change
and make minor edits.\
''')
{bold_red}ERROR:{reset} Please edit your merge request and make sure the setting
{black_white} Allow commits from members who can merge to the target branch{reset}
is checked so that maintainers can rebase your change and make minor edits.\
'''.format(**ansi_codes))
return False
except KeyError:
sys.stderr.write('This appears to be a merge request, but we were not able to fetch the "Allow commits" status\n')