Skip to content

Commit 59dba70

Browse files
committed
[server] Get repository suggestions from all auth providers
1 parent a0dcef2 commit 59dba70

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -997,33 +997,33 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
997997
}
998998

999999
public async getSuggestedContextURLs(ctx: TraceContext): Promise<string[]> {
1000-
const user = this.checkUser("getSuggestedContextURLs");
1000+
this.checkUser("getSuggestedContextURLs");
10011001
const suggestions: string[] = [];
1002+
const logCtx: LogContext = { userId: user.id };
10021003

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!)
10041005
const promises = [];
10051006

10061007
// Example repositories
10071008
promises.push(this.getFeaturedRepositories(ctx).then(exampleRepos => {
1008-
// log('got example repos', exampleRepos);
10091009
exampleRepos.forEach(r => suggestions.push(r.url));
1010+
}).catch(error => {
1011+
log.error(logCtx, 'Could not get example repositories', error);
10101012
}));
10111013

10121014
// 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 });
10241020
userRepos.forEach(r => suggestions.push(r.cloneUrl.replace(/\.git$/, '')));
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+
}));
10271027

10281028
// Recent repositories
10291029
promises.push(this.getWorkspaces(ctx, { /* limit: 20 */ }).then(workspaces => {
@@ -1033,6 +1033,8 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
10331033
suggestions.push(repoUrl);
10341034
}
10351035
});
1036+
}).catch(error => {
1037+
log.error(logCtx, 'Could not fetch recent workspace repositories', error);
10361038
}));
10371039

10381040
await Promise.allSettled(promises);

0 commit comments

Comments
 (0)