mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 21:59:05 +00:00
refactor(migrations): gitLabAutomerge and azureAutoComplete (#14975)
This commit is contained in:
parent
927bb5f37b
commit
5a70fa8805
4 changed files with 81 additions and 5 deletions
|
@ -189,11 +189,6 @@ export function migrateConfig(config: RenovateConfig): MigratedConfig {
|
|||
if (subMigrate.isMigrated) {
|
||||
migratedConfig[key] = subMigrate.migratedConfig;
|
||||
}
|
||||
} else if (key === 'azureAutoComplete' || key === 'gitLabAutomerge') {
|
||||
if (migratedConfig[key] !== undefined) {
|
||||
migratedConfig.platformAutomerge = migratedConfig[key];
|
||||
}
|
||||
delete migratedConfig[key];
|
||||
}
|
||||
|
||||
const migratedTemplates = {
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
import { AzureGitLabAutomergeMigration } from './azure-gitlab-automerge-migration';
|
||||
|
||||
describe('config/migrations/custom/azure-gitlab-automerge-migration', () => {
|
||||
it('should migrate non undefined gitLabAutomerge', () => {
|
||||
expect(AzureGitLabAutomergeMigration).toMigrate(
|
||||
{
|
||||
gitLabAutomerge: true,
|
||||
},
|
||||
{
|
||||
platformAutomerge: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should just remove undefined gitLabAutomerge', () => {
|
||||
expect(AzureGitLabAutomergeMigration).toMigrate(
|
||||
{
|
||||
gitLabAutomerge: undefined,
|
||||
},
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
it('should override platformAutomerge when gitLabAutomerge defined', () => {
|
||||
expect(AzureGitLabAutomergeMigration).toMigrate(
|
||||
{
|
||||
gitLabAutomerge: true,
|
||||
platformAutomerge: false,
|
||||
},
|
||||
{
|
||||
platformAutomerge: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should migrate non undefined azureAutoComplete', () => {
|
||||
expect(AzureGitLabAutomergeMigration).toMigrate(
|
||||
{
|
||||
azureAutoComplete: true,
|
||||
},
|
||||
{
|
||||
platformAutomerge: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should just remove undefined azureAutoComplete', () => {
|
||||
expect(AzureGitLabAutomergeMigration).toMigrate(
|
||||
{
|
||||
azureAutoComplete: undefined,
|
||||
},
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
it('should override platformAutomerge when azureAutoComplete defined', () => {
|
||||
expect(AzureGitLabAutomergeMigration).toMigrate(
|
||||
{
|
||||
azureAutoComplete: true,
|
||||
platformAutomerge: false,
|
||||
},
|
||||
{
|
||||
platformAutomerge: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
import { AbstractMigration } from '../base/abstract-migration';
|
||||
|
||||
export class AzureGitLabAutomergeMigration extends AbstractMigration {
|
||||
override readonly deprecated = true;
|
||||
override readonly propertyName = /^azureAutoComplete$|^gitLabAutomerge$/;
|
||||
|
||||
override run(value: unknown): void {
|
||||
if (value !== undefined) {
|
||||
this.setHard('platformAutomerge', value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import { AutomergeMigration } from './custom/automerge-migration';
|
|||
import { AutomergeMinorMigration } from './custom/automerge-minor-migration';
|
||||
import { AutomergePatchMigration } from './custom/automerge-patch-migration';
|
||||
import { AutomergeTypeMigration } from './custom/automerge-type-migration';
|
||||
import { AzureGitLabAutomergeMigration } from './custom/azure-gitlab-automerge-migration';
|
||||
import { BaseBranchMigration } from './custom/base-branch-migration';
|
||||
import { BinarySourceMigration } from './custom/binary-source-migration';
|
||||
import { BranchNameMigration } from './custom/branch-name-migration';
|
||||
|
@ -77,6 +78,7 @@ export class MigrationsService {
|
|||
AutomergeMinorMigration,
|
||||
AutomergePatchMigration,
|
||||
AutomergeTypeMigration,
|
||||
AzureGitLabAutomergeMigration,
|
||||
BaseBranchMigration,
|
||||
BinarySourceMigration,
|
||||
BranchNameMigration,
|
||||
|
|
Loading…
Reference in a new issue