mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
refactor(migrations): automergePatch (#14637)
This commit is contained in:
parent
e99b1daf57
commit
47feeb4f43
4 changed files with 64 additions and 4 deletions
|
@ -201,10 +201,6 @@ export function migrateConfig(
|
||||||
} else if (key === 'separateMajorReleases') {
|
} else if (key === 'separateMajorReleases') {
|
||||||
delete migratedConfig.separateMultipleMajor;
|
delete migratedConfig.separateMultipleMajor;
|
||||||
migratedConfig.separateMajorMinor = val;
|
migratedConfig.separateMajorMinor = val;
|
||||||
} else if (key === 'automergePatch') {
|
|
||||||
migratedConfig.patch = migratedConfig.patch || {};
|
|
||||||
migratedConfig.patch.automerge = !!val;
|
|
||||||
delete migratedConfig[key];
|
|
||||||
} else if (
|
} else if (
|
||||||
key === 'automerge' &&
|
key === 'automerge' &&
|
||||||
is.string(val) &&
|
is.string(val) &&
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
import { AutomergePatchMigration } from './automerge-patch-migration';
|
||||||
|
|
||||||
|
describe('config/migrations/custom/automerge-patch-migration', () => {
|
||||||
|
it('should migrate value to object', () => {
|
||||||
|
expect(AutomergePatchMigration).toMigrate(
|
||||||
|
{
|
||||||
|
automergePatch: 'some-value',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
patch: {
|
||||||
|
automerge: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should migrate value to object and concat with existing minor object', () => {
|
||||||
|
expect(AutomergePatchMigration).toMigrate(
|
||||||
|
{
|
||||||
|
automergePatch: 'some-value',
|
||||||
|
patch: {
|
||||||
|
matchFiles: ['test'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
patch: {
|
||||||
|
automerge: true,
|
||||||
|
matchFiles: ['test'],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should ignore non object minor value', () => {
|
||||||
|
expect(AutomergePatchMigration).toMigrate(
|
||||||
|
{
|
||||||
|
automergePatch: 'some-value',
|
||||||
|
patch: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
patch: {
|
||||||
|
automerge: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
15
lib/config/migrations/custom/automerge-patch-migration.ts
Normal file
15
lib/config/migrations/custom/automerge-patch-migration.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import is from '@sindresorhus/is';
|
||||||
|
import { AbstractMigration } from '../base/abstract-migration';
|
||||||
|
|
||||||
|
export class AutomergePatchMigration extends AbstractMigration {
|
||||||
|
override readonly deprecated = true;
|
||||||
|
override readonly propertyName = 'automergePatch';
|
||||||
|
|
||||||
|
override run(value: unknown): void {
|
||||||
|
const patch = this.get('patch');
|
||||||
|
|
||||||
|
const newPatch = is.object(patch) ? patch : {};
|
||||||
|
newPatch.automerge = Boolean(value);
|
||||||
|
this.setHard('patch', newPatch);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import { RemovePropertyMigration } from './base/remove-property-migration';
|
||||||
import { RenamePropertyMigration } from './base/rename-property-migration';
|
import { RenamePropertyMigration } from './base/rename-property-migration';
|
||||||
import { AutomergeMajorMigration } from './custom/automerge-major-migration';
|
import { AutomergeMajorMigration } from './custom/automerge-major-migration';
|
||||||
import { AutomergeMinorMigration } from './custom/automerge-minor-migration';
|
import { AutomergeMinorMigration } from './custom/automerge-minor-migration';
|
||||||
|
import { AutomergePatchMigration } from './custom/automerge-patch-migration';
|
||||||
import { AutomergeTypeMigration } from './custom/automerge-type-migration';
|
import { AutomergeTypeMigration } from './custom/automerge-type-migration';
|
||||||
import { BinarySourceMigration } from './custom/binary-source-migration';
|
import { BinarySourceMigration } from './custom/binary-source-migration';
|
||||||
import { CompatibilityMigration } from './custom/compatibility-migration';
|
import { CompatibilityMigration } from './custom/compatibility-migration';
|
||||||
|
@ -59,6 +60,7 @@ export class MigrationsService {
|
||||||
static readonly customMigrations: ReadonlyArray<MigrationConstructor> = [
|
static readonly customMigrations: ReadonlyArray<MigrationConstructor> = [
|
||||||
AutomergeMajorMigration,
|
AutomergeMajorMigration,
|
||||||
AutomergeMinorMigration,
|
AutomergeMinorMigration,
|
||||||
|
AutomergePatchMigration,
|
||||||
AutomergeTypeMigration,
|
AutomergeTypeMigration,
|
||||||
BinarySourceMigration,
|
BinarySourceMigration,
|
||||||
CompatibilityMigration,
|
CompatibilityMigration,
|
||||||
|
|
Loading…
Reference in a new issue