@@ -997,33 +997,33 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
997
997
}
998
998
999
999
public async getSuggestedContextURLs ( ctx : TraceContext ) : Promise < string [ ] > {
1000
- const user = this . checkUser ( "getSuggestedContextURLs" ) ;
1000
+ this . checkUser ( "getSuggestedContextURLs" ) ;
1001
1001
const suggestions : string [ ] = [ ] ;
1002
+ const logCtx : LogContext = { userId : user . id } ;
1002
1003
1003
- // Fetch all data sources in parallel for maximum speed (don't await before `Promise.allSettled(promises)` below!)
1004
+ // Fetch all data sources in parallel for maximum speed (don't await in this scope before `Promise.allSettled(promises)` below!)
1004
1005
const promises = [ ] ;
1005
1006
1006
1007
// Example repositories
1007
1008
promises . push ( this . getFeaturedRepositories ( ctx ) . then ( exampleRepos => {
1008
- // log('got example repos', exampleRepos);
1009
1009
exampleRepos . forEach ( r => suggestions . push ( r . url ) ) ;
1010
+ } ) . catch ( error => {
1011
+ log . error ( logCtx , 'Could not get example repositories' , error ) ;
1010
1012
} ) ) ;
1011
1013
1012
1014
// User repositories
1013
- user . identities . forEach ( identity => {
1014
- const provider = {
1015
- 'Public-GitLab' : 'gitlab.com' ,
1016
- 'Public-GitHub' : 'github.com' ,
1017
- 'Public-Bitbucket' : 'bitbucket.org' ,
1018
- } [ identity . authProviderId ] ;
1019
- if ( ! provider ) {
1020
- return ;
1021
- }
1022
- promises . push ( this . getProviderRepositoriesForUser ( ctx , { provider } ) . then ( userRepos => {
1023
- // log('got', provider, 'user repos', userRepos)
1015
+ promises . push ( this . getAuthProviders ( ctx ) . then ( authProviders => Promise . all ( authProviders . map ( async ( p ) => {
1016
+ // TODO(janx): Refactor this in order not to limit results to app installations & not fetch projects.
1017
+ // This should be entirely about proposing great matches for a user, no matter an app is installed.
1018
+ try {
1019
+ const userRepos = await this . getProviderRepositoriesForUser ( ctx , { provider : p . host } ) ;
1024
1020
userRepos . forEach ( r => suggestions . push ( r . cloneUrl . replace ( / \. g i t $ / , '' ) ) ) ;
1025
- } ) ) ;
1026
- } ) ;
1021
+ } catch ( error ) {
1022
+ log . debug ( logCtx , 'Could not get user repositories from App for ' + p . host , error ) ;
1023
+ }
1024
+ } ) ) ) . catch ( error => {
1025
+ log . error ( logCtx , 'Could not get auth providers' , error ) ;
1026
+ } ) ) ;
1027
1027
1028
1028
// Recent repositories
1029
1029
promises . push ( this . getWorkspaces ( ctx , { /* limit: 20 */ } ) . then ( workspaces => {
@@ -1033,6 +1033,8 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1033
1033
suggestions . push ( repoUrl ) ;
1034
1034
}
1035
1035
} ) ;
1036
+ } ) . catch ( error => {
1037
+ log . error ( logCtx , 'Could not fetch recent workspace repositories' , error ) ;
1036
1038
} ) ) ;
1037
1039
1038
1040
await Promise . allSettled ( promises ) ;
0 commit comments