Skip to content

Commit 7ae75d2

Browse files
DanielNoordjacobtylerwalls
authored andcommitted
Put fatal messages at the top in the primer comment
1 parent b221134 commit 7ae75d2

File tree

1 file changed

+46
-17
lines changed

1 file changed

+46
-17
lines changed

tests/primer/primer_tool.py

+46-17
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,56 @@ def _create_comment(
160160

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

163+
# Create comment for new messages
164+
count = 1
165+
fatal_count = 1
166+
new_non_fatal_messages = ""
167+
new_fatal_messages = ""
168+
if new_messages:
169+
print("Now emitted:")
170+
for message in new_messages:
171+
if message["type"] == "fatal":
172+
filepath = str(message["path"]).replace(
173+
str(package_data.clone_directory), ""
174+
)
175+
new_fatal_messages += (
176+
f"{fatal_count}) {message['symbol']}:\n*{message['message']}*\n"
177+
"**Please check your changes on the following file**:\n"
178+
f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
179+
)
180+
print(message)
181+
fatal_count += 1
182+
else:
183+
filepath = str(message["path"]).replace(
184+
str(package_data.clone_directory), ""
185+
)
186+
new_non_fatal_messages += (
187+
f"{count}) {message['symbol']}:\n*{message['message']}*\n"
188+
f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
189+
)
190+
print(message)
191+
count += 1
192+
193+
if new_fatal_messages:
194+
comment += (
195+
"The following **fatal messages** are now emitted: 💣💥\n\n<details>\n\n"
196+
+ new_fatal_messages
197+
+ "\n</details>\n\n"
198+
)
199+
if new_non_fatal_messages:
200+
comment += (
201+
"The following messages are now emitted:\n\n<details>\n\n"
202+
+ new_non_fatal_messages
203+
+ "\n</details>\n\n"
204+
)
205+
206+
# Create comment for missing messages
207+
count = 1
163208
if missing_messages:
164209
comment += (
165210
"The following messages are no longer emitted:\n\n<details>\n\n"
166211
)
167212
print("No longer emitted:")
168-
count = 1
169213
for message in missing_messages:
170214
comment += f"{count}) {message['symbol']}:\n*{message['message']}*\n"
171215
filepath = str(message["path"]).replace(
@@ -175,22 +219,7 @@ def _create_comment(
175219
count += 1
176220
print(message)
177221
if missing_messages:
178-
comment += "\n</details>\n"
179-
180-
count = 1
181-
if new_messages:
182-
comment += "The following messages are now emitted:\n\n<details>\n\n"
183-
print("Now emitted:")
184-
for message in new_messages:
185-
comment += f"{count}) {message['symbol']}:\n*{message['message']}*\n"
186-
filepath = str(message["path"]).replace(
187-
str(package_data.clone_directory), ""
188-
)
189-
comment += f"{package_data.url}/blob/{package_data.branch}{filepath}#L{message['line']}\n"
190-
count += 1
191-
print(message)
192-
if new_messages:
193-
comment += "\n</details>\n"
222+
comment += "\n</details>\n\n"
194223

195224
if comment == "":
196225
comment = "🤖 According to the primer, this change has **no effect** on the checked open source code. 🤖🎉"

0 commit comments

Comments
 (0)