Skip to content

Commit

Permalink
feat(manager/pip-compile): Change fileMatch behaviour to target pip-c…
Browse files Browse the repository at this point in the history
…ompile output files (#26858)

Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
3 people committed Feb 13, 2024
1 parent ea5e20e commit 2df7ef5
Show file tree
Hide file tree
Showing 11 changed files with 484 additions and 166 deletions.
32 changes: 32 additions & 0 deletions lib/config/migration.spec.ts
Expand Up @@ -668,6 +668,38 @@ describe('config/migration', () => {
expect(migratedConfig).toMatchSnapshot();
});

it('it migrates pip-compile', () => {
const config: RenovateConfig = {
'pip-compile': {
enabled: true,
fileMatch: [
'(^|/)requirements\\.in$',
'(^|/)requirements-fmt\\.in$',
'(^|/)requirements-lint\\.in$',
'.github/workflows/requirements.in',
'(^|/)debian_packages/private/third_party/requirements\\.in$',
'(^|/).*?requirements.*?\\.in$',
],
},
};
const { isMigrated, migratedConfig } =
configMigration.migrateConfig(config);
expect(isMigrated).toBeTrue();
expect(migratedConfig).toEqual({
'pip-compile': {
enabled: true,
fileMatch: [
'(^|/)requirements\\.txt$',
'(^|/)requirements-fmt\\.txt$',
'(^|/)requirements-lint\\.txt$',
'.github/workflows/requirements.txt',
'(^|/)debian_packages/private/third_party/requirements\\.txt$',
'(^|/).*?requirements.*?\\.txt$',
],
},
});
});

it('it migrates gradle-lite', () => {
const config: RenovateConfig = {
'gradle-lite': {
Expand Down
14 changes: 14 additions & 0 deletions lib/config/migration.ts
Expand Up @@ -150,6 +150,20 @@ export function migrateConfig(config: RenovateConfig): MigratedConfig {
}
}
}
if (
is.nonEmptyObject(migratedConfig['pip-compile']) &&
is.nonEmptyArray(migratedConfig['pip-compile'].fileMatch)
) {
migratedConfig['pip-compile'].fileMatch = migratedConfig[
'pip-compile'
].fileMatch.map((fileMatch) => {
const match = fileMatch as string;
if (match.endsWith('.in')) {
return match.replace(/\.in$/, '.txt');
}
return match.replace(/\.in\$$/, '.txt$');
});
}
if (is.nonEmptyArray(migratedConfig.matchManagers)) {
if (migratedConfig.matchManagers.includes('gradle-lite')) {
if (!migratedConfig.matchManagers.includes('gradle')) {
Expand Down
@@ -0,0 +1,18 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# ./pip-compile-wrapper requirements.in
#
certifi==2023.11.17
# via requests
charset-normalizer==3.3.2
# via requests
idna==3.6
# via requests
markupsafe==2.1.4
# via jinja2
requests==2.31.0
# via -r requirements.in
urllib3==2.1.0
# via requests

0 comments on commit 2df7ef5

Please sign in to comment.