Skip to content

Commit fc3eed1

Browse files
[Github] Reformat strings for code format action (#75764)
Before this patch, there was a regression in comment formatting due to some code formatting in bd3e8eb. This was fixed in 428660c. Github interprets a tab before a string as starting code formatting. The message that indicted the code formatting in a PR had been fixed was refactored to a python multi-line string, but with a tab in front, causing these messages to be rendered as code blocks in Github, instead of as intended. This patch builds upon the original fix to reformat the strings so that they fit within ~80 character lines and are simpler to modify in the future, hopefully removing traps like the one that caused the original issue.
1 parent f9c9088 commit fc3eed1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

llvm/utils/git/code-format-helper.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ def run(self, changed_files: List[str], args: FormatArgs) -> bool:
130130

131131
if diff is None:
132132
if should_update_gh:
133-
comment_text = f"""
134-
:white_check_mark: With the latest revision this PR passed the {self.friendly_name}.
135-
"""
133+
comment_text = (
134+
":white_check_mark: With the latest revision "
135+
f"this PR passed the {self.friendly_name}."
136+
)
136137
self.update_pr(comment_text, args, create_new=False)
137138
return True
138139
elif len(diff) > 0:
@@ -141,15 +142,17 @@ def run(self, changed_files: List[str], args: FormatArgs) -> bool:
141142
self.update_pr(comment_text, args, create_new=True)
142143
else:
143144
print(
144-
f"Warning: {self.friendly_name}, {self.name} detected some issues with your code formatting..."
145+
f"Warning: {self.friendly_name}, {self.name} detected "
146+
"some issues with your code formatting..."
145147
)
146148
return False
147149
else:
148150
# The formatter failed but didn't output a diff (e.g. some sort of
149151
# infrastructure failure).
150-
comment_text = f"""
151-
:warning: The {self.friendly_name} failed without printing a diff. Check the logs for stderr output. :warning:
152-
"""
152+
comment_text = (
153+
f":warning: The {self.friendly_name} failed without printing "
154+
"a diff. Check the logs for stderr output. :warning:"
155+
)
153156
self.update_pr(comment_text, args, create_new=False)
154157
return False
155158

0 commit comments

Comments
 (0)