Skip to content

Commit

Permalink
fix: adapt sourcegraph api & typo (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
conwnet authored Jan 23, 2024
1 parent a891c67 commit ec24e80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions extensions/github1s/src/adapters/sourcegraph/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ import { getSymbolReferences } from './reference';
import { getRepository } from './repository';
import { getTextSearchResults } from './search';

type SupportedPlatfrom = 'github' | 'gitlab' | 'bitbucket';
type SupportedPlatform = 'github' | 'gitlab' | 'bitbucket';

export class SourcegraphDataSource extends DataSource {
private static instanceMap: Map<SupportedPlatfrom, SourcegraphDataSource> = new Map();
private static instanceMap: Map<SupportedPlatform, SourcegraphDataSource> = new Map();
private refsPromiseMap: Map<string, Promise<{ branches: Branch[]; tags: Tag[] }>> = new Map();
private repositoryPromiseMap: Map<string, Promise<{ name: string; defaultBranch: string } | null>> = new Map();
private fileTypeMap: Map<string, FileType> = new Map(); // cache if path is a directory
private matchedRefsMap: Map<string, string[]> = new Map();
private textEncodder = new TextEncoder();
private textEncoder = new TextEncoder();

public static getInstance(platfrom: SupportedPlatfrom): SourcegraphDataSource {
if (!SourcegraphDataSource.instanceMap.has(platfrom)) {
SourcegraphDataSource.instanceMap.set(platfrom, new SourcegraphDataSource(platfrom));
public static getInstance(platform: SupportedPlatform): SourcegraphDataSource {
if (!SourcegraphDataSource.instanceMap.has(platform)) {
SourcegraphDataSource.instanceMap.set(platform, new SourcegraphDataSource(platform));
}
return SourcegraphDataSource.instanceMap.get(platfrom)!;
return SourcegraphDataSource.instanceMap.get(platform)!;
}

private constructor(private platform: SupportedPlatfrom) {
private constructor(private platform: SupportedPlatform) {
super();
}

Expand Down Expand Up @@ -110,7 +110,7 @@ export class SourcegraphDataSource extends DataSource {
}
// TODO: support binary files for other platforms
const { content } = await readFile(this.buildRepository(repo), ref, path);
return { content: this.textEncodder.encode(content) };
return { content: this.textEncoder.encode(content) };
}

async prepareAllRefs(repo: string) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/sourcegraph/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DirectoryQuery = gql`
repository(name: $repository) {
commit(rev: $ref) {
tree(path: $path) {
entries(first: ${FILE_COUNT_LIMIT}, recursive: $recursive, recursiveSingleChild: false) {
entries(first: ${FILE_COUNT_LIMIT}, recursive: $recursive) {
path
isDirectory
# TODO submodule don't work now
Expand Down

0 comments on commit ec24e80

Please sign in to comment.