Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(migrations): automergeMajor (#14634)
- Loading branch information
1 parent
90e5182
commit 0b54d5e
Showing
4 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lib/config/migrations/custom/automerge-major-migration.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { AutomergeMajorMigration } from './automerge-major-migration'; | ||
|
||
describe('config/migrations/custom/automerge-major-migration', () => { | ||
it('should migrate value to object', () => { | ||
expect(AutomergeMajorMigration).toMigrate( | ||
{ | ||
automergeMajor: 'some-value', | ||
}, | ||
{ | ||
major: { | ||
automerge: true, | ||
}, | ||
} | ||
); | ||
}); | ||
|
||
it('should migrate value to object and concat with existing minor object', () => { | ||
expect(AutomergeMajorMigration).toMigrate( | ||
{ | ||
automergeMajor: 'some-value', | ||
major: { | ||
matchFiles: ['test'], | ||
}, | ||
}, | ||
{ | ||
major: { | ||
automerge: true, | ||
matchFiles: ['test'], | ||
}, | ||
} | ||
); | ||
}); | ||
|
||
it('should ignore non object minor value', () => { | ||
expect(AutomergeMajorMigration).toMigrate( | ||
{ | ||
automergeMajor: 'some-value', | ||
major: null, | ||
}, | ||
{ | ||
major: { | ||
automerge: true, | ||
}, | ||
} | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import is from '@sindresorhus/is'; | ||
import { AbstractMigration } from '../base/abstract-migration'; | ||
|
||
export class AutomergeMajorMigration extends AbstractMigration { | ||
override readonly deprecated = true; | ||
override readonly propertyName = 'automergeMajor'; | ||
|
||
override run(value: unknown): void { | ||
const major = this.get('major'); | ||
|
||
const newMajor = is.object(major) ? major : {}; | ||
newMajor.automerge = Boolean(value); | ||
this.setHard('major', newMajor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters