Skip to content

Commit d773ea8

Browse files
committed
squash: removing comments and todos
1 parent 4763890 commit d773ea8

File tree

6 files changed

+21
-89
lines changed

6 files changed

+21
-89
lines changed

workspaces/bulk-import/plugins/bulk-import-backend/src/gitlab/GitlabAppManager.test.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,9 @@ import {
2222
CustomSingleInstanceGitlabCredentialsProvider,
2323
} from './GitlabAppManager';
2424

25-
const octokit = {
26-
paginate: async (fn: any) => (await fn()).data,
27-
apps: {
28-
listInstallations: jest.fn(),
29-
listReposAccessibleToInstallation: jest.fn(),
30-
createInstallationAccessToken: jest.fn(),
31-
},
32-
};
33-
34-
function createOctokit() {
35-
return octokit;
36-
}
37-
38-
jest.mock('@octokit/rest', () => {
39-
return { Octokit: createOctokit };
40-
});
41-
4225
describe('CustomSingleInstanceGithubCredentialsProvider tests', () => {
43-
// let gitlab: ExtendedGitlabCredentialsProvider;
44-
4526
beforeEach(() => {
4627
jest.resetAllMocks();
47-
// gitlab = CustomSingleInstanceGitlabCredentialsProvider.create({
48-
// host: 'gitlab.com',
49-
// token: 'hardcoded_token',
50-
// apiBaseUrl: '',
51-
// baseUrl: 'http://gitlab.com',
52-
// });
5328
});
5429

5530
describe('CustomSingleInstanceGithubCredentialsProvider #GetAllCredentials Tests', () => {

workspaces/bulk-import/plugins/bulk-import-backend/src/gitlab/gitlabApiService.test.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -213,30 +213,6 @@ describe('GitlabApiService tests', () => {
213213
});
214214

215215
it('returns list of errors if they occur during the repository fetch phase', async () => {
216-
// octokit.rest.users.getByUsername.mockImplementationOnce(async () => {
217-
// const githubDownError = new Error(
218-
// "The Unicorns have taken over. We're doing our best to get them under control and get Github back up and running",
219-
// );
220-
// githubDownError.name = '503 Service Unavailable';
221-
// throw githubDownError;
222-
// });
223-
// octokit.rest.repos.listForAuthenticatedUser.mockImplementationOnce(
224-
// async () => {
225-
// const customError = new Error('This is taking quite a while');
226-
// customError.name = '504 Gateway Timeout';
227-
// throw customError;
228-
// },
229-
// );
230-
// octokit.apps.listReposAccessibleToInstallation
231-
// .mockImplementationOnce(async () => {
232-
// const unauthorizedError = new Error('Bad credentials');
233-
// unauthorizedError.name = '401 Unauthorized';
234-
// throw unauthorizedError;
235-
// })
236-
// .mockReturnValue({
237-
// data: ghRepos,
238-
// });
239-
240216
gitlabkit.Projects.all.mockImplementationOnce(async () => {
241217
const unauthorizedError = new Error('401 Unauthorized');
242218
unauthorizedError.name = '401 Unauthorized';

workspaces/bulk-import/plugins/bulk-import-backend/src/gitlab/utils/repoUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import type {
2525
import gitUrlParse from 'git-url-parse';
2626

2727
import { getBranchName } from '../../catalog/catalogUtils';
28-
// import { logErrorIfNeeded } from '../../helpers';
2928
import {
3029
DefaultPageNumber,
3130
DefaultPageSize,
@@ -154,7 +153,7 @@ export async function addGitlabTokenRepositories(
154153
/**
155154
* The Projects.all method with the membership: true option will grab all the repositories/projects the gitlab token has explicit access to.
156155
* These would include repositories they own, repositories where they are a collaborator,
157-
* and repositories that they can access through an organization membership(TODO: see if that is true in gitlab).
156+
* and repositories that they can access through an organization membership.
158157
*/
159158
const { data, paginationInfo } = await gitlab.Projects.all({
160159
membership: true,

workspaces/bulk-import/plugins/bulk-import-backend/src/gitlab/utils/utils.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,6 @@ export async function getCredentialsForConfig(
101101
});
102102
}
103103

104-
// export async function extractConfigAndCreds(
105-
// githubCredentialsProvider: CustomGithubCredentialsProvider,
106-
// integrations: ScmIntegrations,
107-
// input: {
108-
// repoUrl: string;
109-
// defaultBranch?: string;
110-
// },
111-
// ) {
112-
// const ghConfig = integrations.github.byUrl(input.repoUrl)?.config;
113-
// if (!ghConfig) {
114-
// throw new Error(`Could not find GH integration from ${input.repoUrl}`);
115-
// }
116-
117-
// const credentials = await githubCredentialsProvider.getAllCredentials({
118-
// host: ghConfig.host,
119-
// });
120-
// if (credentials.length === 0) {
121-
// throw new Error(`No credentials for GH integration`);
122-
// }
123-
124-
// const gitUrl = gitUrlParse(input.repoUrl);
125-
// return { ghConfig, credentials, gitUrl };
126-
// }
127-
128104
export function handleError(
129105
deps: {
130106
logger: LoggerService;

workspaces/bulk-import/plugins/bulk-import-backend/src/service/handlers/import/bulkImports.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,12 @@ async function createPR(
307307
(await catalogInfoGenerator.generateDefaultCatalogInfoContent(
308308
req.repository.url,
309309
)),
310-
prTitle: req[req.approvalTool === 'GITLAB' ? 'gitlab' : 'github']?.pullRequest?.title ?? `Add ${catalogFileName}`,
310+
prTitle:
311+
req[req.approvalTool === 'GITLAB' ? 'gitlab' : 'github']?.pullRequest
312+
?.title ?? `Add ${catalogFileName}`,
311313
prBody:
312-
req[req.approvalTool === 'GITLAB' ? 'gitlab' : 'github']?.pullRequest?.body ??
314+
req[req.approvalTool === 'GITLAB' ? 'gitlab' : 'github']?.pullRequest
315+
?.body ??
313316
`
314317
This pull request adds a **Backstage entity metadata file** to this repository so that the component can be added to a Backstage application.
315318
@@ -347,7 +350,10 @@ async function handleAddedReposFromCreateImportJobs(
347350
if (!hasLocation) {
348351
continue;
349352
}
350-
const gitApiService = req.approvalTool === 'GITLAB' ? deps.gitlabApiService : deps.githubApiService;
353+
const gitApiService =
354+
req.approvalTool === 'GITLAB'
355+
? deps.gitlabApiService
356+
: deps.githubApiService;
351357
const hasCatalogInfoFileInRepo = await gitApiService.hasFileInRepo({
352358
repoUrl: req.repository.url,
353359
defaultBranch: req.repository.defaultBranch,
@@ -400,7 +406,10 @@ async function handlePrCreationRequest(
400406
req.repository.url,
401407
req.repository.defaultBranch,
402408
);
403-
const gitApiService = req.approvalTool === 'GITLAB' ? deps.gitlabApiService : deps.githubApiService;
409+
const gitApiService =
410+
req.approvalTool === 'GITLAB'
411+
? deps.gitlabApiService
412+
: deps.githubApiService;
404413
const prToRepo = await createPR(
405414
gitApiService,
406415
deps.logger,
@@ -411,7 +420,6 @@ async function handlePrCreationRequest(
411420
);
412421
if (prToRepo.errors && prToRepo.errors.length > 0) {
413422
return {
414-
// TODO: should approvalTool be a param
415423
errors: prToRepo.errors,
416424
status: 'PR_ERROR',
417425
repository: req.repository,
@@ -435,7 +443,6 @@ async function handlePrCreationRequest(
435443
req.repository.defaultBranch,
436444
);
437445
return {
438-
// TODO: should approvalTool be a param
439446
status: 'ADDED',
440447
lastUpdate: prToRepo.lastUpdate,
441448
repository: {
@@ -447,7 +454,6 @@ async function handlePrCreationRequest(
447454
}
448455

449456
return {
450-
// TODO: should approvalTool be a param
451457
approvalTool: req.approvalTool ?? 'GIT',
452458
errors: prToRepo.errors,
453459
status: 'WAIT_PR_APPROVAL',
@@ -457,7 +463,6 @@ async function handlePrCreationRequest(
457463
name: gitUrl.name,
458464
organization: gitUrl.organization,
459465
},
460-
//TODO: also add gitlab based on ApprovalTool?
461466
[req.approvalTool === 'GITLAB' ? 'gitlab' : 'github']: {
462467
pullRequest: {
463468
url: prToRepo.prUrl,
@@ -528,7 +533,6 @@ export async function createImportJobs(
528533
result.push(await handlePrCreationRequest(deps, req, gitUrl));
529534
} catch (error: any) {
530535
result.push({
531-
// TODO: should approvalTool be a param
532536
errors: [error.message],
533537
status: 'PR_ERROR',
534538
repository: {
@@ -572,7 +576,6 @@ async function dryRunCreateImportJobs(
572576
);
573577
}
574578
result.push({
575-
// TODO: should approvalTool be a param
576579
errors: dryRunChecks.dryRunStatuses,
577580
catalogEntityName: req.catalogEntityName,
578581
repository: {
@@ -611,7 +614,10 @@ async function performDryRunChecks(
611614
return {};
612615
};
613616

614-
const gitApiService = req.approvalTool === 'GITLAB' ? deps.gitlabApiService : deps.githubApiService;
617+
const gitApiService =
618+
req.approvalTool === 'GITLAB'
619+
? deps.gitlabApiService
620+
: deps.githubApiService;
615621
const checkEmptyRepo = async (): Promise<{
616622
dryRunStatuses?: CreateImportDryRunStatus[];
617623
errors?: string[];
@@ -648,7 +654,8 @@ async function performDryRunChecks(
648654
dryRunStatuses?: CreateImportDryRunStatus[];
649655
errors?: string[];
650656
}> => {
651-
const gitDirLocation = req.approvalTool === 'GITLAB' ? '.gitlab' : '.github';
657+
const gitDirLocation =
658+
req.approvalTool === 'GITLAB' ? '.gitlab' : '.github';
652659
const exists = await gitApiService.hasFileInRepo({
653660
repoUrl: req.repository.url,
654661
defaultBranch: req.repository.defaultBranch,
@@ -774,7 +781,7 @@ export async function findImportStatusByRepo(
774781
body: openImportPr.prBody,
775782
catalogInfoContent: openImportPr.prCatalogInfoContent,
776783
},
777-
}
784+
};
778785

779786
result.lastUpdate = openImportPr.lastUpdate;
780787
} catch (error: any) {

workspaces/bulk-import/plugins/bulk-import-backend/src/service/handlers/organization/organizations.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export async function findAllOrganizations(
6868
// sorting the output to make it deterministic and easy to navigate in the UI
6969
const organizations = sortOrgs(orgMap);
7070

71-
// TODO: Add the approvalTool?
7271
return {
7372
statusCode: 200,
7473
responseBody: {

0 commit comments

Comments
 (0)