Skip to content

Commit

Permalink
perf(manager/pep621): do sync packages on pdm lockfile updates (#22508)
Browse files Browse the repository at this point in the history
  • Loading branch information
secustor authored May 30, 2023
1 parent 0e74b3b commit 2b0a609
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/modules/manager/pep621/artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ requires-python = "<3.9"
'&& ' +
'install-tool pdm v2.5.0 ' +
'&& ' +
'pdm update dep1' +
'pdm update --no-sync dep1' +
'"',
options: {
cwd: '/tmp/github/some/repo',
Expand Down
12 changes: 6 additions & 6 deletions lib/modules/manager/pep621/processors/pdm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('modules/manager/pep621/processors/pdm', () => {
'&& ' +
'install-tool pdm v2.5.0 ' +
'&& ' +
'pdm update dep1' +
'pdm update --no-sync dep1' +
'"',
},
]);
Expand Down Expand Up @@ -173,16 +173,16 @@ describe('modules/manager/pep621/processors/pdm', () => {
]);
expect(execSnapshots).toMatchObject([
{
cmd: 'pdm update dep1 dep2',
cmd: 'pdm update --no-sync dep1 dep2',
},
{
cmd: 'pdm update -G group1 dep3 dep4',
cmd: 'pdm update --no-sync -G group1 dep3 dep4',
},
{
cmd: 'pdm update -dG group2 dep5 dep6',
cmd: 'pdm update --no-sync -dG group2 dep5 dep6',
},
{
cmd: 'pdm update -dG group3 dep7 dep8',
cmd: 'pdm update --no-sync -dG group3 dep7 dep8',
},
]);
});
Expand Down Expand Up @@ -224,7 +224,7 @@ describe('modules/manager/pep621/processors/pdm', () => {
]);
expect(execSnapshots).toMatchObject([
{
cmd: 'pdm update',
cmd: 'pdm update --no-sync',
options: {
cwd: '/tmp/github/some/repo/folder',
},
Expand Down
18 changes: 14 additions & 4 deletions lib/modules/manager/pep621/processors/pdm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import type { PyProject } from '../schema';
import { depTypes, parseDependencyGroupRecord } from '../utils';
import type { PyProjectProcessor } from './types';

const pdmUpdateCMD = 'pdm update --no-sync';

export class PdmProcessor implements PyProjectProcessor {
process(project: PyProject, deps: PackageDependency[]): PackageDependency[] {
const pdm = project.tool?.pdm;
Expand Down Expand Up @@ -87,7 +89,7 @@ export class PdmProcessor implements PyProjectProcessor {
// else only update specific packages
const cmds: string[] = [];
if (isLockFileMaintenance) {
cmds.push('pdm update');
cmds.push(pdmUpdateCMD);
} else {
cmds.push(...generateCMDs(updatedDeps));
}
Expand Down Expand Up @@ -135,16 +137,24 @@ function generateCMDs(updatedDeps: Upgrade[]): string[] {
switch (dep.depType) {
case depTypes.optionalDependencies: {
const [group, name] = dep.depName!.split('/');
addPackageToCMDRecord(packagesByCMD, `pdm update -G ${group}`, name);
addPackageToCMDRecord(
packagesByCMD,
`${pdmUpdateCMD} -G ${group}`,
name
);
break;
}
case depTypes.pdmDevDependencies: {
const [group, name] = dep.depName!.split('/');
addPackageToCMDRecord(packagesByCMD, `pdm update -dG ${group}`, name);
addPackageToCMDRecord(
packagesByCMD,
`${pdmUpdateCMD} -dG ${group}`,
name
);
break;
}
default: {
addPackageToCMDRecord(packagesByCMD, `pdm update`, dep.packageName!);
addPackageToCMDRecord(packagesByCMD, pdmUpdateCMD, dep.packageName!);
}
}
}
Expand Down

0 comments on commit 2b0a609

Please sign in to comment.