Skip to content

Put fatal messages at the top in the primer comment #6744

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

Merged
merged 1 commit into from
May 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 46 additions & 17 deletions tests/primer/primer_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,56 @@ def _create_comment(

comment += f"\n\n**Effect on [{package}]({self.packages[package].url}):**\n"

# Create comment for new messages
count = 1
fatal_count = 1
new_non_fatal_messages = ""
new_fatal_messages = ""
if new_messages:
print("Now emitted:")
for message in new_messages:
if message["type"] == "fatal":
filepath = str(message["path"]).replace(
str(package_data.clone_directory), ""
)
new_fatal_messages += (
f"{fatal_count}) {message['symbol']}:\n*{message['message']}*\n"
"**Please check your changes on the following file**:\n"
f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
)
print(message)
fatal_count += 1
else:
filepath = str(message["path"]).replace(
str(package_data.clone_directory), ""
)
new_non_fatal_messages += (
f"{count}) {message['symbol']}:\n*{message['message']}*\n"
f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
)
print(message)
count += 1

if new_fatal_messages:
comment += (
"The following **fatal messages** are now emitted: πŸ’£πŸ’₯\n\n<details>\n\n"
+ new_fatal_messages
+ "\n</details>\n\n"
)
if new_non_fatal_messages:
comment += (
"The following messages are now emitted:\n\n<details>\n\n"
+ new_non_fatal_messages
+ "\n</details>\n\n"
)

# Create comment for missing messages
count = 1
if missing_messages:
comment += (
"The following messages are no longer emitted:\n\n<details>\n\n"
)
print("No longer emitted:")
count = 1
for message in missing_messages:
comment += f"{count}) {message['symbol']}:\n*{message['message']}*\n"
filepath = str(message["path"]).replace(
Expand All @@ -175,22 +219,7 @@ def _create_comment(
count += 1
print(message)
if missing_messages:
comment += "\n</details>\n"

count = 1
if new_messages:
comment += "The following messages are now emitted:\n\n<details>\n\n"
print("Now emitted:")
for message in new_messages:
comment += f"{count}) {message['symbol']}:\n*{message['message']}*\n"
filepath = str(message["path"]).replace(
str(package_data.clone_directory), ""
)
comment += f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
count += 1
print(message)
if new_messages:
comment += "\n</details>\n"
comment += "\n</details>\n\n"

if comment == "":
comment = "πŸ€– According to the primer, this change has **no effect** on the checked open source code. πŸ€–πŸŽ‰"
Expand Down