@@ -22,7 +22,6 @@ def __init__(self):
2222 self .bot_login = (
2323 bot_username if bot_username .endswith ("[bot]" ) else f"{ bot_username } [bot]"
2424 )
25-
2625 if self .github_token and self .repository_name :
2726 try :
2827 self .github = Github (self .github_token )
@@ -68,11 +67,8 @@ def get_issue_projects(self, owner, repo_name, issue_number):
6867 """
6968 variables = {"owner" : owner , "repo" : repo_name , "issueNumber" : issue_number }
7069 headers , result = self .github .requester .graphql_query (query , variables )
71- print (f"DEBUG: Raw GraphQL response: { result } " )
72-
7370 if "errors" in result :
7471 raise ValueError (f"GraphQL API Permission Error: { result ['errors' ]} " )
75-
7672 repo_data = result .get ("data" , {}).get ("repository" )
7773 if not repo_data :
7874 raise ValueError (
@@ -108,13 +104,11 @@ def validate_pr_issues(self, pr):
108104 if not self .github or not self .repository_name :
109105 print ("GitHub client or repository name not initialized" )
110106 return False
111-
112107 pr_author = (
113108 pr .user .login
114109 if pr .user and isinstance (getattr (pr .user , "login" , None ), str )
115110 else ""
116111 )
117-
118112 exclude_authors_env = os .environ .get (
119113 "EXCLUDE_PR_AUTHORS" , DEFAULT_EXCLUDE_PR_AUTHORS
120114 )
@@ -124,36 +118,31 @@ def validate_pr_issues(self, pr):
124118 if pr_author in excluded_authors :
125119 print (f"Author { pr_author } is in the exclude list. Proceeding." )
126120 return True
127-
128121 author_association = str (getattr (pr , "author_association" , "" ) or "" )
129122 if author_association in MAINTAINER_ROLES :
130123 print (
131124 f"Author { pr_author } is exempt due to association: "
132125 f"{ author_association } . Proceeding."
133126 )
134127 return True
135-
136128 from utils import extract_all_linked_issues
137129
138130 pr_body = pr .body if isinstance (pr .body , str ) else ""
139131 linked_issues = extract_all_linked_issues (pr_body , self .repository_name )
140132 if not linked_issues :
141133 print ("No linked issues found in PR body for external contributor." )
142134 return False
143-
144135 current_org = self .repository_name .split ("/" )[0 ].lower ()
145136 required_projects = {
146137 self ._project_title_key (p ) for p in REQUIRED_CONTRIBUTOR_PROJECTS
147138 }
148-
149139 for owner , repo_name , issue_number in linked_issues :
150140 if owner .lower () != current_org :
151141 print (
152142 f"Issue { owner } /{ repo_name } #{ issue_number } does not belong "
153143 f"to organization { current_org } , skipping validation."
154144 )
155145 continue
156-
157146 try :
158147 from github import GithubException
159148
@@ -167,19 +156,16 @@ def validate_pr_issues(self, pr):
167156 continue
168157 print (f"Error fetching issue { owner } /{ repo_name } #{ issue_number } : { e } " )
169158 raise
170-
171159 if issue .pull_request :
172160 print (
173161 f"Reference { owner } /{ repo_name } #{ issue_number } is a pull request, skipping validation."
174162 )
175163 continue
176-
177164 if issue .state != "open" :
178165 print (
179166 f"Issue { owner } /{ repo_name } #{ issue_number } is not open, skipping validation."
180167 )
181168 continue
182-
183169 issue_labels = [label .name .lower () for label in issue .labels ]
184170 valid_labels = [
185171 lbl for lbl in issue_labels if lbl not in INVALID_ISSUE_LABELS
@@ -195,22 +181,14 @@ def validate_pr_issues(self, pr):
195181 "invalid/wontfix label, skipping validation."
196182 )
197183 continue
198-
199184 try :
200185 projects = self .get_issue_projects (owner , repo_name , issue_number )
201186 except Exception as e :
202187 print (
203188 f"Error fetching projects for issue { owner } /{ repo_name } #{ issue_number } : { e } "
204189 )
205190 raise
206-
207- print (
208- f"DEBUG: Raw projects for { owner } /{ repo_name } #{ issue_number } : { projects } "
209- )
210191 project_keys = [self ._project_title_key (p ) for p in projects ]
211- print (f"DEBUG: Normalized project keys: { project_keys } " )
212- print (f"DEBUG: Required project keys: { required_projects } " )
213-
214192 has_valid_project = any (key in required_projects for key in project_keys )
215193 if has_valid_project :
216194 print (
@@ -223,12 +201,10 @@ def validate_pr_issues(self, pr):
223201 f"to any required project (found: { projects or 'none' } ), "
224202 "skipping validation."
225203 )
226-
227204 return False
228205
229206 def get_bot_comment (self , pr , comment_type , after_date = None , issue_comments = None ):
230207 """Get the comment of this bot with the given marker if it exists.
231-
232208 If ``after_date`` is provided, only considers comments posted after that date.
233209 """
234210 try :
@@ -251,7 +227,6 @@ def get_bot_comment(self, pr, comment_type, after_date=None, issue_comments=None
251227
252228 def has_bot_comment (self , pr , comment_type , after_date = None , issue_comments = None ):
253229 """Check if PR already has a specific type of bot comment.
254-
255230 Uses HTML markers. If ``after_date`` is provided,
256231 only considers comments posted after that date.
257232 """
@@ -277,11 +252,14 @@ def get_invalid_unvalidated_issue_comment(self, pr_author):
277252 "request.\n \n "
278253 "An issue is considered validated when it is open, has an appropriate "
279254 "label other than `invalid` or `wontfix`, and is assigned to one of "
280- "the OpenWISP contributor project boards mentioned in the "
281- "contributing guidelines.\n \n "
282- "Please see the OpenWISP policy on unsolicited and AI-assisted "
283- "contributions:\n "
284- "https://openwisp.io/docs/dev/general/code-of-conduct.html\n \n "
255+ "the project boards mentioned in the "
256+ "[OpenWISP Contributing Guidelines]"
257+ "(https://openwisp.io/docs/dev/developer/contributing.html).\n \n "
258+ "Please see the [OpenWISP Anti AI Spam Policy]"
259+ "(https://openwisp.io/docs/dev/general/code-of-conduct.html).\n \n "
260+ "Feel free to join the [OpenWISP dev chatroom]"
261+ "(https://matrix.to/#/#openwisp_development:gitter.im) "
262+ "to coordinate with the development team.\n \n "
285263 "If this is not resolved within 24 hours, this pull request "
286264 "will be closed automatically. "
287265 "Thank you for your understanding."
0 commit comments