11use 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,
54} ;
6- use anyhow:: Context ;
75use reqwest:: Method ;
86use std:: collections:: { HashMap , HashSet } ;
97
@@ -14,16 +12,6 @@ pub(crate) trait GithubRead {
1412 /// Get the owners of an org
1513 fn org_owners ( & self , org : & str ) -> anyhow:: Result < HashSet < u64 > > ;
1614
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-
2715 /// Get all teams associated with a org
2816 ///
2917 /// Returns a list of tuples of team name and slug
@@ -124,56 +112,6 @@ impl GithubRead for GitHubApiRead {
124112 Ok ( owners)
125113 }
126114
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-
177115 fn org_teams ( & self , org : & str ) -> anyhow:: Result < Vec < ( String , String ) > > {
178116 let mut teams = Vec :: new ( ) ;
179117
@@ -308,7 +246,6 @@ impl GithubRead for GitHubApiRead {
308246 query($owner: String!, $name: String!) {
309247 repository(owner: $owner, name: $name) {
310248 id
311- databaseId
312249 autoMergeAllowed
313250 description
314251 homepageUrl
@@ -328,7 +265,6 @@ impl GithubRead for GitHubApiRead {
328265 // Equivalent of `node_id` of the Rest API
329266 id : String ,
330267 // Equivalent of `id` of the Rest API
331- database_id : u64 ,
332268 auto_merge_allowed : Option < bool > ,
333269 description : Option < String > ,
334270 homepage_url : Option < String > ,
@@ -345,7 +281,6 @@ impl GithubRead for GitHubApiRead {
345281 ) ?;
346282
347283 let repo = result. repository . map ( |repo_response| Repo {
348- repo_id : repo_response. database_id ,
349284 node_id : repo_response. id ,
350285 name : repo. to_string ( ) ,
351286 description : repo_response. description . unwrap_or_default ( ) ,
0 commit comments