Skip to content

Commit

Permalink
Poetry: let datasource set default registry when possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbsgilbs committed Sep 21, 2019
1 parent 93c072d commit 0256ad0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
8 changes: 4 additions & 4 deletions lib/manager/poetry/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ function extractFromSection(

function extractRegistries(pyprojectfile: PoetryFile): string[] {
const sources = pyprojectfile.tool.poetry.source;
const registryUrls: string[] = ['https://pypi.org/pypi/'];

if (!Array.isArray(sources)) {
return registryUrls;
if (!Array.isArray(sources) || sources.length === 0) {
return [];
}

const registryUrls: string[] = [];
for (const source of sources) {
if (source.url) {
registryUrls.push(source.url);
}
}

return registryUrls;
return [...registryUrls, 'https://pypi.org/pypi/'];
}
14 changes: 1 addition & 13 deletions test/manager/poetry/__snapshots__/extract.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`lib/manager/poetry/extract extractPackageFile() can parse empty registries 1`] = `
Array [
"https://pypi.org/pypi/",
]
`;

exports[`lib/manager/poetry/extract extractPackageFile() can parse missing registries 1`] = `
Array [
"https://pypi.org/pypi/",
]
`;

exports[`lib/manager/poetry/extract extractPackageFile() extracts multiple dependencies (with dep = {version = "1.2.3"} case) 1`] = `
Array [
Object {
Expand Down Expand Up @@ -171,9 +159,9 @@ Array [

exports[`lib/manager/poetry/extract extractPackageFile() extracts registries 1`] = `
Array [
"https://pypi.org/pypi/",
"https://foo.bar/simple/",
"https://bar.baz/+simple/",
"https://pypi.org/pypi/",
]
`;

Expand Down
6 changes: 2 additions & 4 deletions test/manager/poetry/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ describe('lib/manager/poetry/extract', () => {
});
it('can parse empty registries', () => {
const res = extractPackageFile(pyproject7toml, config);
expect(res.registryUrls).toMatchSnapshot();
expect(res.registryUrls).toHaveLength(1);
expect(res.registryUrls).toEqual([]);
});
it('can parse missing registries', () => {
const res = extractPackageFile(pyproject1toml, config);
expect(res.registryUrls).toMatchSnapshot();
expect(res.registryUrls).toHaveLength(1);
expect(res.registryUrls).toEqual([]);
});
it('skips git dependencies', () => {
const content =
Expand Down

0 comments on commit 0256ad0

Please sign in to comment.