Skip to content

Commit 216dc01

Browse files
committed
fix a few things and add bbs impl for searchRepos
1 parent 558dbf7 commit 216dc01

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

components/server/src/auth/rate-limiter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const defaultFunctions: FunctionsConfig = {
6666
getFeaturedRepositories: { group: "default", points: 1 },
6767
getSuggestedContextURLs: { group: "default", points: 1 },
6868
getSuggestedRepositories: { group: "default", points: 1 },
69+
searchRepositories: { group: "default", points: 1 },
6970
getWorkspace: { group: "default", points: 1 },
7071
isWorkspaceOwner: { group: "default", points: 1 },
7172
getOwnerToken: { group: "default", points: 1 },

components/server/src/bitbucket-server/bitbucket-server-repository-provider.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ export class BitbucketServerRepositoryProvider implements RepositoryProvider {
190190

191191
// TODO: implement repo search
192192
public async searchRepos(user: User, searchString: string): Promise<RepositoryInfo[]> {
193-
return [];
193+
const repos = await this.api.getRepos(user, { searchString, maxPages: 1, limit: 10 });
194+
195+
const result: RepositoryInfo[] = [];
196+
repos.forEach((r) => {
197+
const cloneUrl = r.links.clone.find((u) => u.name === "http")?.href;
198+
if (cloneUrl) {
199+
result.push({
200+
url: cloneUrl.replace("http://", "https://"),
201+
name: r.name,
202+
});
203+
}
204+
});
205+
206+
return result;
194207
}
195208
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
18841884
ctx: TraceContext,
18851885
params: SearchRepositoriesParams,
18861886
): Promise<SuggestedRepository[]> {
1887-
const user = await this.checkAndBlockUser("getProviderRepositoriesForUser");
1887+
const user = await this.checkAndBlockUser("searchRepositories");
18881888

18891889
const logCtx: LogContext = { userId: user.id };
18901890

0 commit comments

Comments
 (0)