From c7c8ba9f8a80a9e817756716082ec1f3119f1874 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Fri, 18 Jun 2021 09:20:14 +0200 Subject: [PATCH] fix: Revert "refactor(pip_requirements): extractAllPackageFiles (#10414)" This reverts commit 015391c70e7eed35ab610e4f3c484899acf5ef97. Closes #10485 --- .../__fixtures__/requirements1.txt | 2 +- .../__snapshots__/extract.spec.ts.snap | 31 ------------------- lib/manager/pip_requirements/extract.spec.ts | 16 ++-------- lib/manager/pip_requirements/extract.ts | 24 -------------- lib/manager/pip_requirements/index.ts | 2 +- 5 files changed, 4 insertions(+), 71 deletions(-) diff --git a/lib/manager/pip_requirements/__fixtures__/requirements1.txt b/lib/manager/pip_requirements/__fixtures__/requirements1.txt index fbee0f3f42..23aaa25e90 100644 --- a/lib/manager/pip_requirements/__fixtures__/requirements1.txt +++ b/lib/manager/pip_requirements/__fixtures__/requirements1.txt @@ -3,4 +3,4 @@ some-package==0.3.1 some-other-package==1.0.0 not_semver==1.9 -unconstrained + diff --git a/lib/manager/pip_requirements/__snapshots__/extract.spec.ts.snap b/lib/manager/pip_requirements/__snapshots__/extract.spec.ts.snap index b0c232a42c..325dfdbde1 100644 --- a/lib/manager/pip_requirements/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/pip_requirements/__snapshots__/extract.spec.ts.snap @@ -63,37 +63,6 @@ Array [ ] `; -exports[`manager/pip_requirements/extract extractPackageFile() extracts using extractAllPackageFiles 1`] = ` -Array [ - Object { - "deps": Array [ - Object { - "currentValue": "==0.3.1", - "currentVersion": "0.3.1", - "datasource": "pypi", - "depName": "some-package", - }, - Object { - "currentValue": "==1.0.0", - "currentVersion": "1.0.0", - "datasource": "pypi", - "depName": "some-other-package", - }, - Object { - "currentValue": "==1.9", - "currentVersion": "1.9", - "datasource": "pypi", - "depName": "not_semver", - }, - ], - "packageFile": "unused_file_name", - "registryUrls": Array [ - "http://example.com/private-pypi/", - ], - }, -] -`; - exports[`manager/pip_requirements/extract extractPackageFile() handles comments and commands 1`] = ` Array [ Object { diff --git a/lib/manager/pip_requirements/extract.spec.ts b/lib/manager/pip_requirements/extract.spec.ts index 471d7bd72b..b73af574fa 100644 --- a/lib/manager/pip_requirements/extract.spec.ts +++ b/lib/manager/pip_requirements/extract.spec.ts @@ -1,8 +1,6 @@ -import { fs, getName, loadFixture } from '../../../test/util'; +import { getName, loadFixture } from '../../../test/util'; import { setAdminConfig } from '../../config/admin'; -import { extractAllPackageFiles, extractPackageFile } from './extract'; - -jest.mock('../../util/fs'); +import { extractPackageFile } from './extract'; const requirements1 = loadFixture('requirements1.txt'); const requirements2 = loadFixture('requirements2.txt'); @@ -43,16 +41,6 @@ describe(getName(), () => { expect(res.registryUrls).toEqual(['http://example.com/private-pypi/']); expect(res.deps).toHaveLength(3); }); - it('extracts using extractAllPackageFiles', async () => { - fs.readLocalFile.mockResolvedValueOnce(requirements1); - const outerRes = await extractAllPackageFiles(config, [ - 'unused_file_name', - ]); - expect(outerRes).toMatchSnapshot(); - const [res] = outerRes; - expect(res.registryUrls).toEqual(['http://example.com/private-pypi/']); - expect(res.deps).toHaveLength(3); - }); it('extracts multiple dependencies', () => { const res = extractPackageFile( requirements2, diff --git a/lib/manager/pip_requirements/extract.ts b/lib/manager/pip_requirements/extract.ts index 64070e88b1..f5e357bbea 100644 --- a/lib/manager/pip_requirements/extract.ts +++ b/lib/manager/pip_requirements/extract.ts @@ -4,7 +4,6 @@ import { getAdminConfig } from '../../config/admin'; import * as datasourcePypi from '../../datasource/pypi'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; -import { readLocalFile } from '../../util/fs'; import { isSkipComment } from '../../util/ignore'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; @@ -102,26 +101,3 @@ export function extractPackageFile( } return res; } - -export async function extractAllPackageFiles( - config: ExtractConfig, - packageFiles: string[] -): Promise<PackageFile[]> { - const requirementsFiles: PackageFile[] = []; - for (const packageFile of packageFiles) { - const content = await readLocalFile(packageFile, 'utf8'); - // istanbul ignore else - if (content) { - const deps = extractPackageFile(content, packageFile, config); - if (deps) { - requirementsFiles.push({ - packageFile, - ...deps, - }); - } - } else { - logger.debug({ packageFile }, 'requirements file has no content'); - } - } - return requirementsFiles; -} diff --git a/lib/manager/pip_requirements/index.ts b/lib/manager/pip_requirements/index.ts index b57282d7f9..b2c951aa37 100644 --- a/lib/manager/pip_requirements/index.ts +++ b/lib/manager/pip_requirements/index.ts @@ -1,7 +1,7 @@ import { LANGUAGE_PYTHON } from '../../constants/languages'; export { updateArtifacts } from './artifacts'; -export { extractAllPackageFiles } from './extract'; +export { extractPackageFile } from './extract'; export { getRangeStrategy } from './range'; export const language = LANGUAGE_PYTHON; -- GitLab