[llvm] [Github] Fix github automation script on empty descriptions (PR #71274)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 4 00:51:00 PDT 2023


https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/71274

Before this patch, the github automation script would fail when trying to escape the text of a PR/issue description that was empty as the Github library returns None instead of an empty string in those scenarios. This patch special cases this and makes the escape function return an empty string when given a value of None.

>From 52101554f613da6aba031d65ceb7d036b76102fa Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Sat, 4 Nov 2023 00:49:23 -0700
Subject: [PATCH] [Github] Fix github automation script on empty descriptions

Before this patch, the github automation script would fail when trying
to escape the text of a PR/issue description that was empty as the
Github library returns None instead of an empty string in those
scenarios. This patch special cases this and makes the escape function
return an empty string when given a value of None.
---
 llvm/utils/git/github-automation.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index 52523704fe82dc8..ad1878d41193920 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -48,6 +48,11 @@ def _get_curent_team(team_name, teams) -> Optional[github.Team.Team]:
 
 
 def escape_description(str):
+    # If the description of an issue/pull request is empty, the Github API
+    # library returns None instead of an empty string. Handle this here to
+    # avoid failures from trying to manipulate None.
+    if str is None:
+        return ""
     # https://github.com/github/markup/issues/1168#issuecomment-494946168
     str = html.escape(str, False)
     # '@' followed by alphanum is a user name



More information about the llvm-commits mailing list