43
43
44
44
45
45
def search_issues (
46
- search_query : str , github_connection : github3 .GitHub
46
+ search_query : str , github_connection : github3 .GitHub , owner : str , repository : str
47
47
) -> List [github3 .search .IssueSearchResult ]: # type: ignore
48
48
"""
49
49
Searches for issues/prs/discussions in a GitHub repository that match
@@ -52,6 +52,8 @@ def search_issues(
52
52
Args:
53
53
search_query (str): The search query to use for finding issues/prs/discussions.
54
54
github_connection (github3.GitHub): A connection to the GitHub API.
55
+ owner (str): The owner of the repository to search in.
56
+ repository (str): The repository to search in.
55
57
56
58
Returns:
57
59
List[github3.search.IssueSearchResult]: A list of issues that match the search query.
@@ -67,11 +69,13 @@ def search_issues(
67
69
issues .append (issue )
68
70
except github3 .exceptions .ForbiddenError :
69
71
print (
70
- "You do not have permission to view this repository; Check you API Token."
72
+ f "You do not have permission to view this repository ' { repository } ' ; Check your API Token."
71
73
)
72
74
sys .exit (1 )
73
75
except github3 .exceptions .NotFoundError :
74
- print ("The repository could not be found; Check the repository owner and name." )
76
+ print (
77
+ f"The repository could not be found; Check the repository owner and name: '{ owner } /{ repository } "
78
+ )
75
79
sys .exit (1 )
76
80
except github3 .exceptions .ConnectionError :
77
81
print (
@@ -240,27 +244,28 @@ def get_per_issue_metrics(
240
244
return issues_with_metrics , num_issues_open , num_issues_closed
241
245
242
246
243
- def get_owner (
247
+ def get_owner_and_repository (
244
248
search_query : str ,
245
- ) -> Union [ str , None ] :
246
- """Get the owner from the search query.
249
+ ) -> dict :
250
+ """Get the owner and repository from the search query.
247
251
248
252
Args:
249
253
search_query (str): The search query used to search for issues.
250
254
251
255
Returns:
252
- Union[str, None]: The owner.
256
+ dict: A dictionary of owner and repository .
253
257
254
258
"""
255
259
search_query_split = search_query .split (" " )
256
- owner = None
260
+ result = {}
257
261
for item in search_query_split :
258
262
if "repo:" in item and "/" in item :
259
- owner = item .split (":" )[1 ].split ("/" )[0 ]
263
+ result ["owner" ] = item .split (":" )[1 ].split ("/" )[0 ]
264
+ result ["repository" ] = item .split (":" )[1 ].split ("/" )[1 ]
260
265
if "org:" in item or "owner:" in item or "user:" in item :
261
- owner = item .split (":" )[1 ]
266
+ result [ " owner" ] = item .split (":" )[1 ]
262
267
263
- return owner
268
+ return result
264
269
265
270
266
271
def main ():
@@ -297,8 +302,10 @@ def main():
297
302
max_comments_eval = int (env_vars .max_comments_eval )
298
303
heavily_involved_cutoff = int (env_vars .heavily_involved_cutoff )
299
304
300
- # Get the repository owner and name from the search query
301
- owner = get_owner (search_query )
305
+ # Get the owner and repository from the search query
306
+ owner_and_repository = get_owner_and_repository (search_query )
307
+ owner = owner_and_repository .get ("owner" )
308
+ repository = owner_and_repository .get ("repository" )
302
309
303
310
if owner is None :
304
311
raise ValueError (
@@ -323,7 +330,7 @@ def main():
323
330
write_to_markdown (None , None , None , None , None , None , None , None )
324
331
return
325
332
else :
326
- issues = search_issues (search_query , github_connection )
333
+ issues = search_issues (search_query , github_connection , owner , repository )
327
334
if len (issues ) <= 0 :
328
335
print ("No issues found" )
329
336
write_to_markdown (None , None , None , None , None , None , None , None )
0 commit comments