1
1
use crate :: github:: api:: {
2
- BranchProtection , GraphNode , GraphNodes , GraphPageInfo , HttpClient , Login , OrgAppInstallation ,
3
- Repo , RepoAppInstallation , RepoTeam , RepoUser , Team , TeamMember , TeamRole , team_node_id,
4
- url:: GitHubUrl , user_node_id,
2
+ BranchProtection , GraphNode , GraphNodes , GraphPageInfo , HttpClient , Login , Repo , RepoTeam ,
3
+ RepoUser , Team , TeamMember , TeamRole , team_node_id, url:: GitHubUrl , user_node_id,
5
4
} ;
6
- use anyhow:: Context ;
7
5
use reqwest:: Method ;
8
6
use std:: collections:: { HashMap , HashSet } ;
9
7
@@ -14,16 +12,6 @@ pub(crate) trait GithubRead {
14
12
/// Get the owners of an org
15
13
fn org_owners ( & self , org : & str ) -> anyhow:: Result < HashSet < u64 > > ;
16
14
17
- /// Get the app installations of an org
18
- fn org_app_installations ( & self , org : & str ) -> anyhow:: Result < Vec < OrgAppInstallation > > ;
19
-
20
- /// Get the repositories enabled for an app installation.
21
- fn app_installation_repos (
22
- & self ,
23
- installation_id : u64 ,
24
- org : & str ,
25
- ) -> anyhow:: Result < Vec < RepoAppInstallation > > ;
26
-
27
15
/// Get all teams associated with a org
28
16
///
29
17
/// Returns a list of tuples of team name and slug
@@ -124,56 +112,6 @@ impl GithubRead for GitHubApiRead {
124
112
Ok ( owners)
125
113
}
126
114
127
- fn org_app_installations ( & self , org : & str ) -> anyhow:: Result < Vec < OrgAppInstallation > > {
128
- #[ derive( serde:: Deserialize , Debug ) ]
129
- struct InstallationPage {
130
- installations : Vec < OrgAppInstallation > ,
131
- }
132
-
133
- let mut installations = Vec :: new ( ) ;
134
- self . client . rest_paginated (
135
- & Method :: GET ,
136
- & GitHubUrl :: orgs ( org, "installations" ) ?,
137
- |response : InstallationPage | {
138
- installations. extend ( response. installations ) ;
139
- Ok ( ( ) )
140
- } ,
141
- ) ?;
142
- Ok ( installations)
143
- }
144
-
145
- fn app_installation_repos (
146
- & self ,
147
- installation_id : u64 ,
148
- org : & str ,
149
- ) -> anyhow:: Result < Vec < RepoAppInstallation > > {
150
- #[ derive( serde:: Deserialize , Debug ) ]
151
- struct InstallationPage {
152
- repositories : Vec < RepoAppInstallation > ,
153
- }
154
-
155
- let mut installations = Vec :: new ( ) ;
156
- let url = if self . client . github_tokens . is_pat ( ) {
157
- // we are using a PAT
158
- format ! ( "user/installations/{installation_id}/repositories" )
159
- } else {
160
- // we are using a GitHub App
161
- "installation/repositories" . to_string ( )
162
- } ;
163
-
164
- self . client
165
- . rest_paginated (
166
- & Method :: GET ,
167
- & GitHubUrl :: new ( & url, org) ,
168
- |response : InstallationPage | {
169
- installations. extend ( response. repositories ) ;
170
- Ok ( ( ) )
171
- } ,
172
- )
173
- . with_context ( || format ! ( "failed to send rest paginated request to {url}" ) ) ?;
174
- Ok ( installations)
175
- }
176
-
177
115
fn org_teams ( & self , org : & str ) -> anyhow:: Result < Vec < ( String , String ) > > {
178
116
let mut teams = Vec :: new ( ) ;
179
117
@@ -308,7 +246,6 @@ impl GithubRead for GitHubApiRead {
308
246
query($owner: String!, $name: String!) {
309
247
repository(owner: $owner, name: $name) {
310
248
id
311
- databaseId
312
249
autoMergeAllowed
313
250
description
314
251
homepageUrl
@@ -328,7 +265,6 @@ impl GithubRead for GitHubApiRead {
328
265
// Equivalent of `node_id` of the Rest API
329
266
id : String ,
330
267
// Equivalent of `id` of the Rest API
331
- database_id : u64 ,
332
268
auto_merge_allowed : Option < bool > ,
333
269
description : Option < String > ,
334
270
homepage_url : Option < String > ,
@@ -345,7 +281,6 @@ impl GithubRead for GitHubApiRead {
345
281
) ?;
346
282
347
283
let repo = result. repository . map ( |repo_response| Repo {
348
- repo_id : repo_response. database_id ,
349
284
node_id : repo_response. id ,
350
285
name : repo. to_string ( ) ,
351
286
description : repo_response. description . unwrap_or_default ( ) ,
0 commit comments