Skip to content

Commit 4c16888

Browse files
committed
Remove limit of 1000 to repo lists
1 parent fe21a21 commit 4c16888

File tree

5 files changed

+11
-153
lines changed

5 files changed

+11
-153
lines changed

extensions/ql-vscode/src/databases/config/db-config-store.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,10 @@ export class DbConfigStore extends DisposableObject {
147147
await this.writeConfig(config);
148148
}
149149

150-
/**
151-
* Adds a list of remote repositories to an existing repository list and removes duplicates.
152-
* @returns a list of repositories that were not added because the list reached 1000 entries.
153-
*/
154150
public async addRemoteReposToList(
155151
repoNwoList: string[],
156152
parentList: string,
157-
): Promise<string[]> {
153+
): Promise<void> {
158154
if (!this.config) {
159155
throw Error("Cannot add variant analysis repos if config is not loaded");
160156
}
@@ -172,21 +168,15 @@ export class DbConfigStore extends DisposableObject {
172168
...new Set([...parent.repositories, ...repoNwoList]),
173169
];
174170

175-
parent.repositories = newRepositoriesList.slice(0, 1000);
176-
const truncatedRepositories = newRepositoriesList.slice(1000);
171+
parent.repositories = newRepositoriesList;
177172

178173
await this.writeConfig(config);
179-
return truncatedRepositories;
180174
}
181175

182-
/**
183-
* Adds one remote repository
184-
* @returns either nothing, or, if a parentList is given AND the number of repos on that list reaches 1000 returns the repo that was not added.
185-
*/
186176
public async addRemoteRepo(
187177
repoNwo: string,
188178
parentList?: string,
189-
): Promise<string[]> {
179+
): Promise<void> {
190180
if (!this.config) {
191181
throw Error("Cannot add variant analysis repo if config is not loaded");
192182
}
@@ -201,7 +191,6 @@ export class DbConfigStore extends DisposableObject {
201191
);
202192
}
203193

204-
const truncatedRepositories = [];
205194
const config = cloneDbConfig(this.config);
206195
if (parentList) {
207196
const parent = config.databases.variantAnalysis.repositoryLists.find(
@@ -210,15 +199,12 @@ export class DbConfigStore extends DisposableObject {
210199
if (!parent) {
211200
throw Error(`Cannot find parent list '${parentList}'`);
212201
} else {
213-
const newRepositories = [...parent.repositories, repoNwo];
214-
parent.repositories = newRepositories.slice(0, 1000);
215-
truncatedRepositories.push(...newRepositories.slice(1000));
202+
parent.repositories = [...parent.repositories, repoNwo];
216203
}
217204
} else {
218205
config.databases.variantAnalysis.repositories.push(repoNwo);
219206
}
220207
await this.writeConfig(config);
221-
return truncatedRepositories;
222208
}
223209

224210
public async addRemoteOwner(owner: string): Promise<void> {

extensions/ql-vscode/src/databases/db-manager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ export class DbManager extends DisposableObject {
101101
public async addNewRemoteRepo(
102102
nwo: string,
103103
parentList?: string,
104-
): Promise<string[]> {
105-
return await this.dbConfigStore.addRemoteRepo(nwo, parentList);
104+
): Promise<void> {
105+
await this.dbConfigStore.addRemoteRepo(nwo, parentList);
106106
}
107107

108108
public async addNewRemoteReposToList(
109109
nwoList: string[],
110110
parentList: string,
111-
): Promise<string[]> {
112-
return await this.dbConfigStore.addRemoteReposToList(nwoList, parentList);
111+
): Promise<void> {
112+
await this.dbConfigStore.addRemoteReposToList(nwoList, parentList);
113113
}
114114

115115
public async addNewRemoteOwner(owner: string): Promise<void> {

extensions/ql-vscode/src/databases/ui/db-panel.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,7 @@ export class DbPanel extends DisposableObject {
183183
return;
184184
}
185185

186-
const truncatedRepositories = await this.dbManager.addNewRemoteRepo(
187-
nwo,
188-
parentList,
189-
);
190-
191-
if (parentList) {
192-
this.reportAnyTruncatedRepos(truncatedRepositories, parentList);
193-
}
186+
await this.dbManager.addNewRemoteRepo(nwo, parentList);
194187
}
195188

196189
private async addNewRemoteOwner(): Promise<void> {
@@ -415,26 +408,11 @@ export class DbPanel extends DisposableObject {
415408

416409
progress.report({ increment: 10, message: "Processing results..." });
417410

418-
const truncatedRepositories =
419-
await this.dbManager.addNewRemoteReposToList(repositories, listName);
420-
this.reportAnyTruncatedRepos(truncatedRepositories, listName);
411+
await this.dbManager.addNewRemoteReposToList(repositories, listName);
421412
},
422413
);
423414
}
424415

425-
private reportAnyTruncatedRepos(
426-
truncatedRepositories: string[],
427-
listName: string,
428-
) {
429-
if (truncatedRepositories.length > 0) {
430-
void showAndLogErrorMessage(
431-
`Some repositories were not added to '${listName}' because a list can only have 1000 entries. Excluded repositories: ${truncatedRepositories.join(
432-
", ",
433-
)}`,
434-
);
435-
}
436-
}
437-
438416
private async onDidCollapseElement(
439417
event: TreeViewExpansionEvent<DbTreeViewItem>,
440418
): Promise<void> {

extensions/ql-vscode/test/unit-tests/databases/config/db-config-store.test.ts

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ describe("db config store", () => {
262262
});
263263

264264
// Add
265-
const response = await configStore.addRemoteReposToList(
265+
await configStore.addRemoteReposToList(
266266
["owner/repo1", "owner/repo2"],
267267
"list1",
268268
);
@@ -278,72 +278,6 @@ describe("db config store", () => {
278278
name: "list1",
279279
repositories: ["owner/repo1", "owner/repo2"],
280280
});
281-
expect(response).toEqual([]);
282-
283-
configStore.dispose();
284-
});
285-
286-
it("should add no more than 1000 repositories to a remote list when adding multiple repos", async () => {
287-
// Initial set up
288-
const dbConfig = createDbConfig({
289-
remoteLists: [
290-
{
291-
name: "list1",
292-
repositories: [],
293-
},
294-
],
295-
});
296-
297-
const configStore = await initializeConfig(dbConfig, configPath, app);
298-
299-
// Add
300-
const response = await configStore.addRemoteReposToList(
301-
[...Array(1001).keys()].map((i) => `owner/db${i}`),
302-
"list1",
303-
);
304-
305-
// Read the config file
306-
const updatedDbConfig = (await readJSON(configPath)) as DbConfig;
307-
308-
// Check that the config file has been updated
309-
const updatedRemoteDbs = updatedDbConfig.databases.variantAnalysis;
310-
expect(updatedRemoteDbs.repositories).toHaveLength(0);
311-
expect(updatedRemoteDbs.repositoryLists).toHaveLength(1);
312-
expect(updatedRemoteDbs.repositoryLists[0].repositories).toHaveLength(
313-
1000,
314-
);
315-
expect(response).toEqual(["owner/db1000"]);
316-
317-
configStore.dispose();
318-
});
319-
320-
it("should add no more than 1000 repositories to a remote list when adding one repo", async () => {
321-
// Initial set up
322-
const dbConfig = createDbConfig({
323-
remoteLists: [
324-
{
325-
name: "list1",
326-
repositories: [...Array(1000).keys()].map((i) => `owner/db${i}`),
327-
},
328-
],
329-
});
330-
331-
const configStore = await initializeConfig(dbConfig, configPath, app);
332-
333-
// Add
334-
const reponse = await configStore.addRemoteRepo("owner/db1000", "list1");
335-
336-
// Read the config file
337-
const updatedDbConfig = (await readJSON(configPath)) as DbConfig;
338-
339-
// Check that the config file has been updated
340-
const updatedRemoteDbs = updatedDbConfig.databases.variantAnalysis;
341-
expect(updatedRemoteDbs.repositories).toHaveLength(0);
342-
expect(updatedRemoteDbs.repositoryLists).toHaveLength(1);
343-
expect(updatedRemoteDbs.repositoryLists[0].repositories).toHaveLength(
344-
1000,
345-
);
346-
expect(reponse).toEqual(["owner/db1000"]);
347281

348282
configStore.dispose();
349283
});

extensions/ql-vscode/test/unit-tests/databases/db-manager.test.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -115,46 +115,6 @@ describe("db manager", () => {
115115
});
116116
});
117117

118-
it("should return truncated repos when adding multiple repos to a user defined list", async () => {
119-
const dbConfig: DbConfig = createDbConfig({
120-
remoteLists: [
121-
{
122-
name: "my-list-1",
123-
repositories: [...Array(1000).keys()].map((i) => `owner/db${i}`),
124-
},
125-
],
126-
});
127-
128-
await saveDbConfig(dbConfig);
129-
130-
const response = await dbManager.addNewRemoteReposToList(
131-
["owner2/repo2"],
132-
"my-list-1",
133-
);
134-
135-
expect(response).toEqual(["owner2/repo2"]);
136-
});
137-
138-
it("should return truncated repos when adding one repo to a user defined list", async () => {
139-
const dbConfig: DbConfig = createDbConfig({
140-
remoteLists: [
141-
{
142-
name: "my-list-1",
143-
repositories: [...Array(1000).keys()].map((i) => `owner/db${i}`),
144-
},
145-
],
146-
});
147-
148-
await saveDbConfig(dbConfig);
149-
150-
const response = await dbManager.addNewRemoteRepo(
151-
"owner2/repo2",
152-
"my-list-1",
153-
);
154-
155-
expect(response).toEqual(["owner2/repo2"]);
156-
});
157-
158118
it("should add a new remote repo to a user defined list", async () => {
159119
const dbConfig: DbConfig = createDbConfig({
160120
remoteLists: [

0 commit comments

Comments
 (0)