[llvm] Improve the pull-request subcription notification format by adding the description and files statistics (PR #65828)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 02:35:16 PDT 2023
================
@@ -77,23 +85,62 @@ def __init__(self, token: str, repo: str, pr_number: int, label_name: str):
self._team_name = "pr-subscribers-{}".format(label_name).lower()
def run(self) -> bool:
- for team in self.org.get_teams():
- if self.team_name != team.name.lower():
- continue
- try:
- # GitHub limits comments to 65,536 characters, let's limit our comments to 20,000.
- patch = requests.get(self.pr.diff_url).text[0:20000]
- except:
- patch = ""
- comment = (
- "@llvm/{}".format(team.slug)
- + "\n\n<details><summary>Changes</summary><pre>\n"
- + patch
- + "\n</pre></details>"
- )
- self.pr.as_issue().create_comment(comment)
+ patch = None
+ team = self._get_curent_team()
+ if not team:
+ print(f"couldn't find team named {self.team_name}")
+ return False
+
+ # Get statistics for each file
+ diff_stats = f"{self.pr.changed_files} Files Affected:\n\n"
+ for file in self.pr.get_files():
+ diff_stats += f"- ({file.status}) {file.filename} ("
+ if file.additions:
+ diff_stats += f"+{file.additions}"
+ if file.deletions:
+ diff_stats += f"-{file.deletions}"
+ diff_stats += ") "
+ if file.status == "renamed":
+ print(f"(from {file.previous_filename})")
+ diff_stats += "\n"
+ diff_stats += "\n"
+
+ # Get the diff
+ try:
+ patch = requests.get(self.pr.diff_url).text
+ except:
+ patch = ""
+ diff_stats += "\n<pre>\n" + patch
----------------
jayfoad wrote:
Hi, I'm seeing this `<pre>` getting escaped to `<pre>`, so it no longer has the desired effect and the diff looks horrible in the github web UI. Example: https://github.com/llvm/llvm-project/pull/66188#issuecomment-1717259869
https://github.com/llvm/llvm-project/pull/65828
More information about the llvm-commits
mailing list