[llvm] workflows: Add a simple pull request subscription workflow (PR #64913)

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 21:43:28 PDT 2023


================
@@ -65,6 +66,30 @@ def run(self) -> bool:
         return False
 
 
+class PRSubscriber:
+    @property
+    def team_name(self) -> str:
+        return self._team_name
+
+    def __init__(self, token: str, repo: str, pr_number: int, label_name : str):
+        self.repo = github.Github(token).get_repo(repo)
+        self.org = github.Github(token).get_organization(self.repo.organization.login)
+        self.pr = self.repo.get_issue(pr_number).as_pull_request()
+        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:
+                patch = requests.get(self.pr.diff_url).text
+            except:
+                patch = ""
+            comment = "@llvm/{}".format(team.slug) + "\n\n<details><summary>Changes</summary><pre>\n" + patch + "\n</pre></details>"
----------------
tstellar wrote:

Yes, I tested and it shows up in the email notification.  You do have to click in the email to expand the patch (if you are looking at the html version) like you do on the comment, but hopefully that's acceptable.
![Email-Collapased](https://github.com/llvm/llvm-project/assets/143300/5cb1dde0-f64d-46ad-9f57-0d9863ba32f5)
![Email-Expanded](https://github.com/llvm/llvm-project/assets/143300/92ffeef5-2f07-4c11-94cb-1a829f4e23a3)

Can you file an issue for what format you want in the issue notifications?

https://github.com/llvm/llvm-project/pull/64913


More information about the llvm-commits mailing list