Skip to content

Commit

Permalink
feat(manager/poetry): add support for bumpVersion option (#26377)
Browse files Browse the repository at this point in the history
  • Loading branch information
Churro authored Dec 19, 2023
1 parent dc614d0 commit d2536a7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ This is an advance field and it's recommend you seek a config review before appl
## bumpVersion

Currently this setting supports `helmv3`, `npm`, `nuget`, `maven`, `pep621` and `sbt` only, so raise a feature request if you have a use for it with other package managers.
Currently this setting supports `helmv3`, `npm`, `nuget`, `maven`, `pep621`, `poetry` and `sbt` only, so raise a feature request if you have a use for it with other package managers.
Its purpose is if you want Renovate to update the `version` field within your package file any time it updates dependencies within.
Usually this is for automatic release purposes, so that you don't need to add another step after Renovate before you can release a new version.

Expand Down
4 changes: 4 additions & 0 deletions lib/modules/manager/poetry/__snapshots__/extract.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ exports[`modules/manager/poetry/extract extractPackageFile() extracts mixed vers
},
],
"extractedConstraints": {},
"packageFileVersion": "0.1.0",
}
`;

Expand Down Expand Up @@ -427,6 +428,7 @@ exports[`modules/manager/poetry/extract extractPackageFile() extracts multiple d
},
],
"extractedConstraints": {},
"packageFileVersion": "0.1.0",
}
`;

Expand Down Expand Up @@ -555,6 +557,7 @@ exports[`modules/manager/poetry/extract extractPackageFile() handles multiple co
},
],
"extractedConstraints": {},
"packageFileVersion": "0.1.0",
}
`;

Expand Down Expand Up @@ -589,5 +592,6 @@ exports[`modules/manager/poetry/extract extractPackageFile() resolves lockedVers
"extractedConstraints": {
"python": "^3.9",
},
"packageFileVersion": undefined,
}
`;
1 change: 1 addition & 0 deletions lib/modules/manager/poetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GithubReleasesDatasource } from '../../datasource/github-releases';
import { GithubTagsDatasource } from '../../datasource/github-tags';
import { PypiDatasource } from '../../datasource/pypi';

export { bumpPackageVersion } from '../pep621/update';
export { extractPackageFile } from './extract';
export { updateArtifacts } from './artifacts';
export { updateLockedDependency } from './update-locked';
Expand Down
13 changes: 12 additions & 1 deletion lib/modules/manager/poetry/schema.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { PoetrySources } from './schema';
import { PoetrySectionSchema, PoetrySources } from './schema';

describe('modules/manager/poetry/schema', () => {
it('parses project version', () => {
expect(
PoetrySectionSchema.parse({ version: '1.2.3' }).packageFileVersion,
).toBe('1.2.3');

expect(
PoetrySectionSchema.parse({ version: { some: 'value' } })
.packageFileVersion,
).toBeUndefined();
});

describe('PoetrySources', () => {
it('parses default values', () => {
expect(PoetrySources.parse([])).toBeEmptyArray();
Expand Down
4 changes: 3 additions & 1 deletion lib/modules/manager/poetry/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export const PoetrySources = LooseArray(PoetrySource, {

export const PoetrySectionSchema = z
.object({
version: z.string().optional().catch(undefined),
dependencies: withDepType(PoetryDependencies, 'dependencies').optional(),
'dev-dependencies': withDepType(
PoetryDependencies,
Expand All @@ -256,6 +257,7 @@ export const PoetrySectionSchema = z
})
.transform(
({
version,
dependencies = [],
'dev-dependencies': devDependencies = [],
extras: extraDependencies = [],
Expand All @@ -269,7 +271,7 @@ export const PoetrySectionSchema = z
...groupDependencies,
];

const res: PackageFileContent = { deps };
const res: PackageFileContent = { deps, packageFileVersion: version };

if (sourceUrls.length) {
for (const dep of res.deps) {
Expand Down

0 comments on commit d2536a7

Please sign in to comment.