Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: renovatebot/renovate
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 39.144.1
Choose a base ref
...
head repository: renovatebot/renovate
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7f3b76b5ca31e23c25b97082b6482b4f35cdbb59
Choose a head ref
  • 1 commit
  • 2 files changed
  • 2 contributors

Commits on Jan 30, 2025

  1. fix(manager/custom): Support range strategy with custom managers (#33800

    )
    
    Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
    mpkorstanje and viceice authored Jan 30, 2025
    Copy the full SHA
    7f3b76b View commit details
Showing with 37 additions and 3 deletions.
  1. +32 −1 lib/modules/manager/index.spec.ts
  2. +5 −2 lib/modules/manager/index.ts
33 changes: 32 additions & 1 deletion lib/modules/manager/index.spec.ts
Original file line number Diff line number Diff line change
@@ -170,7 +170,7 @@ describe('modules/manager/index', () => {
});

describe('getRangeStrategy', () => {
it('returns null', () => {
it('returns null for a unknown manager', () => {
manager.getManagers().set('dummy', {
defaultConfig: {},
supportedDatasources: [],
@@ -180,6 +180,37 @@ describe('modules/manager/index', () => {
).toBeNull();
});

it('returns null for a undefined manager', () => {
manager.getManagers().set('dummy', {
defaultConfig: {},
supportedDatasources: [],
});
expect(manager.getRangeStrategy({ rangeStrategy: 'auto' })).toBeNull();
});

it('returns non-null for a custom manager', () => {
customManager.getCustomManagers().set('dummy', {
defaultConfig: {},
supportedDatasources: [],
});
expect(
manager.getRangeStrategy({ manager: 'dummy', rangeStrategy: 'auto' }),
).not.toBeNull();
});

it('handles custom managers', () => {
customManager.getCustomManagers().set('dummy', {
defaultConfig: {},
supportedDatasources: [],
// For completeness. Custom managers are configured in json and can not
// provide a range strategy (yet) but the interface allows for it.
getRangeStrategy: () => 'bump',
});
expect(
manager.getRangeStrategy({ manager: 'dummy', rangeStrategy: 'auto' }),
).toBe('bump');
});

it('returns non-null', () => {
manager.getManagers().set('dummy', {
defaultConfig: {},
7 changes: 5 additions & 2 deletions lib/modules/manager/index.ts
Original file line number Diff line number Diff line change
@@ -78,10 +78,13 @@ export function extractPackageFile(

export function getRangeStrategy(config: RangeConfig): RangeStrategy | null {
const { manager, rangeStrategy } = config;
if (!manager || !managers.has(manager)) {
if (!manager) {
return null;
}
const m = managers.get(manager) ?? customManagers.get(manager);
if (!m) {
return null;
}
const m = managers.get(manager)!;
if (m.getRangeStrategy) {
// Use manager's own function if it exists
const managerRangeStrategy = m.getRangeStrategy(config);