mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
feat(manager/gradle): add support for new header used by gradle-consistent-versions plugin (#27895)
This commit is contained in:
parent
a7658221d8
commit
291defc7e1
2 changed files with 17 additions and 6 deletions
|
@ -20,6 +20,18 @@ describe('modules/manager/gradle/extract/consistent-versions-plugin', () => {
|
||||||
expect(usesGcv('othersub/versions.props', fsMock)).toBeFalse();
|
expect(usesGcv('othersub/versions.props', fsMock)).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('detects lock file header introduced with gradle-consistent-versions version 2.20.0', () => {
|
||||||
|
const fsMock = {
|
||||||
|
'build.gradle.kts': `(this file contains) 'com.palantir.consistent-versions'`,
|
||||||
|
'versions.props': `org.apache.lucene:* = 1.2.3`,
|
||||||
|
'versions.lock': stripIndent`
|
||||||
|
# Run ./gradlew writeVersionsLock to regenerate this file
|
||||||
|
org.apache.lucene:lucene-core:1.2.3`,
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(usesGcv('versions.props', fsMock)).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
it('gradle-consistent-versions plugin correct position for CRLF and LF', () => {
|
it('gradle-consistent-versions plugin correct position for CRLF and LF', () => {
|
||||||
const crlfProps = parsePropsFile(`a.b:c.d=1\r\na.b:c.e=2`);
|
const crlfProps = parsePropsFile(`a.b:c.d=1\r\na.b:c.e=2`);
|
||||||
expect(crlfProps).toBeArrayOfSize(2);
|
expect(crlfProps).toBeArrayOfSize(2);
|
||||||
|
@ -47,7 +59,6 @@ describe('modules/manager/gradle/extract/consistent-versions-plugin', () => {
|
||||||
expect(parsedProps[0]).toMatchObject({ size: 1 }); // no 7 is valid exact dep
|
expect(parsedProps[0]).toMatchObject({ size: 1 }); // no 7 is valid exact dep
|
||||||
expect(parsedProps[1]).toMatchObject({ size: 1 }); // no 8 is valid glob dep
|
expect(parsedProps[1]).toMatchObject({ size: 1 }); // no 8 is valid glob dep
|
||||||
|
|
||||||
// lockfile
|
|
||||||
const parsedLock = parseLockFile(stripIndent`
|
const parsedLock = parseLockFile(stripIndent`
|
||||||
# comment:foo.bar:1 (10 constraints: 95be0c15)
|
# comment:foo.bar:1 (10 constraints: 95be0c15)
|
||||||
123.foo:bar:2 (10 constraints: 95be0c15)
|
123.foo:bar:2 (10 constraints: 95be0c15)
|
||||||
|
|
|
@ -8,8 +8,9 @@ import { isDependencyString, versionLikeSubstring } from '../utils';
|
||||||
|
|
||||||
export const VERSIONS_PROPS = 'versions.props';
|
export const VERSIONS_PROPS = 'versions.props';
|
||||||
export const VERSIONS_LOCK = 'versions.lock';
|
export const VERSIONS_LOCK = 'versions.lock';
|
||||||
const LOCKFILE_HEADER_TEXT =
|
export const LOCKFIlE_HEADER_TEXT = regEx(
|
||||||
'# Run ./gradlew --write-locks to regenerate this file';
|
/^# Run \.\/gradlew (?:--write-locks|writeVersionsLock) to regenerate this file/,
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if Palantir gradle-consistent-versions is in use, https://github.com/palantir/gradle-consistent-versions.
|
* Determines if Palantir gradle-consistent-versions is in use, https://github.com/palantir/gradle-consistent-versions.
|
||||||
|
@ -26,9 +27,8 @@ export function usesGcv(
|
||||||
versionsPropsFilename,
|
versionsPropsFilename,
|
||||||
VERSIONS_LOCK,
|
VERSIONS_LOCK,
|
||||||
);
|
);
|
||||||
return (
|
|
||||||
fileContents[versionsLockFile]?.startsWith(LOCKFILE_HEADER_TEXT) ?? false
|
return !!fileContents[versionsLockFile]?.match(LOCKFIlE_HEADER_TEXT);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue