@@ -61,19 +61,22 @@ def github_request_json(url, params=None, limit_results=None):
61
61
continue # and restart the loop
62
62
63
63
if all_results is None :
64
- all_results = data
65
- elif isinstance (all_results , list ) and isinstance (data , list ):
64
+ all_results = data
65
+ # if we come from all_results being a list, then we're extending it.
66
+ elif isinstance (all_results , list ):
66
67
all_results .extend (data )
67
- elif isinstance (all_results , dict ) and isinstance ( data , dict ) :
68
- all_results . update ( data )
68
+ elif isinstance (all_results , dict ) and data . get ( 'total_count' ) != None :
69
+ all_results [ list ( all_results . keys ())[ 1 ]]. extend ( list ( data . values ())[ 1 ] )
69
70
else :
70
- raise TypeError ( "Inconsistent data types received from pagination." )
71
+ all_results . update ( data )
71
72
72
73
# Reset next_url
73
74
next_url = None
74
75
75
76
# Using "limit" we can cap the amount of results in order to prevent huge amounts of requests.
76
- if limit_results == None or len (all_results ) < limit_results :
77
+ if limit_results == None or \
78
+ ((isinstance (all_results , list ) and len (all_results ) < limit_results ) \
79
+ or (isinstance (all_results , dict ) and all_results .get ('total_count' ) != None and len (list (all_results .values ())[1 ]) < limit_results )):
77
80
if 'rel="next"' in links :
78
81
for link in links .split (',' ):
79
82
if 'rel="next"' in link :
@@ -126,18 +129,33 @@ def fetch_repository_custom_values(repo):
126
129
def fetch_repository_public_events (repo ):
127
130
return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /events" )
128
131
132
+ def fetch_repository_commit_comments (repo ):
133
+ return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /comments" )
134
+
135
+ def fetch_repository_issues_comments (repo ):
136
+ return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /issues/comments" )
137
+
138
+ def fetch_repository_pulls_comments (repo ):
139
+ return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /pulls/comments" )
140
+
129
141
def fetch_repository_actions_workflows (repo ):
130
142
return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /actions/workflows" )
131
143
132
- def fetch_repository_actions_artifacts (repo ):
133
- return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /actions/artifacts" )
144
+ def fetch_repository_actions_artifacts (repo , limit ):
145
+ return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /actions/artifacts" , limit_results = limit )
146
+
147
+ def fetch_repository_actions_runs (repo , limit ):
148
+ return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /actions/runs" , limit_results = limit )
134
149
135
150
def fetch_repository_releases (repo ):
136
151
return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /releases" )
137
152
138
153
def fetch_repository_tags (repo ):
139
154
return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /tags" )
140
155
156
+ def fetch_repository_labels (repo ):
157
+ return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /labels" )
158
+
141
159
def fetch_repository_branches (repo ):
142
160
return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /branches" )
143
161
@@ -150,6 +168,9 @@ def fetch_repository_deployments(repo):
150
168
def fetch_repository_environments (repo ):
151
169
return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /environments" )
152
170
171
+ def fetch_environment_protection_rules (repo , environment ):
172
+ return github_request_json (f"{ GITHUB_API_BASE_URL } /repos/{ repo .get ('full_name' )} /environments/{ environment } /deployment_protection_rules" )
173
+
153
174
def fetch_repository_pull_requests (repo ):
154
175
return github_request_json (repo .get ('pulls_url' ).replace ("{/number}" ,"" ), {'state' :'all' })
155
176
0 commit comments