diff --git a/lib/modules/manager/cargo/range.spec.ts b/lib/modules/manager/cargo/range.spec.ts index 0356aac6a8cd22c3c4e9a4a10d87ef857f5ed94e..62c07b1389b2b37cffffe9e509728da6a229e794 100644 --- a/lib/modules/manager/cargo/range.spec.ts +++ b/lib/modules/manager/cargo/range.spec.ts @@ -7,8 +7,19 @@ describe('modules/manager/cargo/range', () => { expect(getRangeStrategy(config)).toBe('widen'); }); + it('returns widen if current value includes <', () => { + const config: RangeConfig = { + rangeStrategy: 'auto', + currentValue: '<1.0.0', + }; + expect(getRangeStrategy(config)).toBe('widen'); + }); + it('defaults to bump', () => { - const config: RangeConfig = { rangeStrategy: 'auto' }; + const config: RangeConfig = { + rangeStrategy: 'auto', + currentValue: '1.0.0', + }; expect(getRangeStrategy(config)).toBe('bump'); }); }); diff --git a/lib/modules/manager/cargo/range.ts b/lib/modules/manager/cargo/range.ts index 8f3d6e7eb54595b8451bd8110e809d31e24b4fea..a04628d55c127d2c3a2c139ac258c435ea5fcfe5 100644 --- a/lib/modules/manager/cargo/range.ts +++ b/lib/modules/manager/cargo/range.ts @@ -2,7 +2,14 @@ import type { RangeStrategy } from '../../../types'; import type { RangeConfig } from '../types'; export function getRangeStrategy({ + currentValue, rangeStrategy, }: RangeConfig): RangeStrategy { - return rangeStrategy === 'auto' ? 'bump' : rangeStrategy; + if (rangeStrategy !== 'auto') { + return rangeStrategy; + } + if (currentValue?.includes('<')) { + return 'widen'; + } + return 'bump'; } diff --git a/lib/modules/manager/cargo/readme.md b/lib/modules/manager/cargo/readme.md index 5b564a57cd76d09b420577ce20631f4de0538b15..5e05f6a22839485de2225f25ece164a816f9fcb4 100644 --- a/lib/modules/manager/cargo/readme.md +++ b/lib/modules/manager/cargo/readme.md @@ -1 +1,6 @@ Extracts dependencies from `Cargo.toml` files, and also updates `Cargo.lock` files too if found. + +When using the default rangeStrategy=auto: + +- If a "less than" instruction is found (e.g. `<2`) then `rangeStrategy=widen` will be selected, +- Otherwise, `rangeStrategy=bump` will be selected.