@@ -158,6 +158,7 @@ def __init__(self):
158
158
'Authorization' : f'Bearer { self ._token } ' ,
159
159
'X-GitHub-Api-Version' : '2022-11-28'
160
160
}
161
+ self ._maintainers = set ()
161
162
os .environ ['GITHUB_AUTH_TOKEN' ] = self ._token
162
163
163
164
def get_pr_author (self ):
@@ -244,6 +245,8 @@ def get_past_contributors(self, project_path):
244
245
245
246
login = commit ['author' ]['login' ]
246
247
verified = commit ['commit' ]['verification' ]['verified' ]
248
+ if login in self ._maintainers :
249
+ continue
247
250
if login not in contributors :
248
251
contributors [login ] = verified
249
252
if verified :
@@ -257,19 +260,25 @@ def get_past_contributors(self, project_path):
257
260
258
261
return all_contributors
259
262
260
- def is_author_internal_member (self ):
261
- """Returns if the author is an internal member."""
263
+ def get_maintainers (self ):
264
+ """Get a list of internal members."""
265
+ if self ._maintainers :
266
+ return self ._maintainers
267
+
262
268
response = requests .get (f'{ BASE_URL } /contents/infra/MAINTAINERS.csv' ,
263
269
headers = self ._headers )
264
270
if not response .ok :
265
- return False
271
+ return self . _maintainers
266
272
267
- maintainers = base64 .b64decode (response .json ()['content' ]).decode ('UTF-8' )
268
- for line in maintainers .split (os .linesep ):
269
- if self ._pr_author == line .split (',' )[2 ]:
270
- return True
273
+ maintainers_file = base64 .b64decode (
274
+ response .json ()['content' ]).decode ('UTF-8' )
275
+ for line in maintainers_file .split (os .linesep ):
276
+ self ._maintainers .add (line .split (',' )[2 ])
277
+ return self ._maintainers
271
278
272
- return False
279
+ def is_author_internal_member (self ):
280
+ """Returns if the author is an internal member."""
281
+ return self ._pr_author in self .get_maintainers ()
273
282
274
283
def has_author_modified_project (self , project_path ):
275
284
"""Checks if the author has modified this project before."""
0 commit comments