Skip to content

Commit

Permalink
Merge branch 'main' into ft/code-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek authored Oct 4, 2023
2 parents 83ebe10 + 07597d5 commit 43e4aec
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
22 changes: 7 additions & 15 deletions components/server/src/github/github-repository-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ export class GithubRepositoryProvider implements RepositoryProvider {
}

public async searchRepos(user: User, searchString: string): Promise<RepositoryInfo[]> {
const logCtx = { userId: user.id };

// graphql api only returns public orgs, so we need to use the rest api to get both public & private orgs
const orgs = await this.github.run(user, async (api) => {
return api.orgs.listMembershipsForAuthenticatedUser({
Expand Down Expand Up @@ -264,19 +262,13 @@ export class GithubRepositoryProvider implements RepositoryProvider {

let repos: RepositoryInfo[] = [];

try {
const result = await this.githubQueryApi.runQuery<SearchReposQueryResponse>(user, repoSearchQuery);
repos = result.data.search.edges.map((edge) => {
return {
name: edge.node.name,
url: edge.node.url,
};
});
} catch (e) {
log.warn(logCtx, "Error searching repos", e, { orgCount: orgFilters.length });

throw e;
}
const result = await this.githubQueryApi.runQuery<SearchReposQueryResponse>(user, repoSearchQuery);
repos = result.data.search.edges.map((edge) => {
return {
name: edge.node.name,
url: edge.node.url,
};
});

return repos;
}
Expand Down
4 changes: 2 additions & 2 deletions components/server/src/gitlab/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export namespace GitLab {
* 20 => Reporter access
* 30 => Developer access
* 40 => Maintainer access
* 50 => Owner accesss
* 50 => Owner access
`*/
access_level: number;
};
Expand All @@ -240,7 +240,7 @@ export namespace GitLab {
* 20 => Reporter access
* 30 => Developer access
* 40 => Maintainer access
* 50 => Owner accesss
* 50 => Owner access
`*/
access_level: number;
};
Expand Down
17 changes: 15 additions & 2 deletions components/server/src/gitlab/gitlab-repository-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,21 @@ export class GitlabRepositoryProvider implements RepositoryProvider {
return result.slice(1).map((c: GitLab.Commit) => c.id);
}

// TODO: implement repo search
public async searchRepos(user: User, searchString: string): Promise<RepositoryInfo[]> {
return [];
const result = await this.gitlab.run<GitLab.Project[]>(user, async (gitlab) => {
return gitlab.Projects.all({
membership: true,
search: searchString,
simple: true,
});
});

if (GitLab.ApiError.is(result)) {
throw result;
}

return result.map((result) => {
return { url: result.web_url, name: result.name };
});
}
}

0 comments on commit 43e4aec

Please sign in to comment.