mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix(bazel): handle url updating instead of urls
This commit is contained in:
parent
9ffe3b0d65
commit
f276e0c301
2 changed files with 32 additions and 2 deletions
|
@ -16,12 +16,20 @@ function updateWithNewVersion(content, currentValue, newValue) {
|
|||
return newContent;
|
||||
}
|
||||
|
||||
function extractUrl(flattened) {
|
||||
const urlMatch = flattened.match(/url="(.*?)"/);
|
||||
if (!urlMatch) {
|
||||
logger.debug('Cannot locate urls in new definition');
|
||||
return null;
|
||||
}
|
||||
return [urlMatch[1]];
|
||||
}
|
||||
|
||||
function extractUrls(content) {
|
||||
const flattened = content.replace(/\n/g, '').replace(/\s/g, '');
|
||||
const urlsMatch = flattened.match(/urls?=\[.*?\]/);
|
||||
if (!urlsMatch) {
|
||||
logger.debug({ content }, 'Cannot locate urls in new definition');
|
||||
return null;
|
||||
return extractUrl(flattened);
|
||||
}
|
||||
const urls = urlsMatch[0]
|
||||
.replace(/urls?=\[/, '')
|
||||
|
|
|
@ -132,6 +132,28 @@ describe('manager/bazel/update', () => {
|
|||
expect(res).not.toEqual(fileWithBzlExtension);
|
||||
expect(res.indexOf('0.8.0')).not.toBe(-1);
|
||||
});
|
||||
it('updates finds url instead of urls', async () => {
|
||||
const upgrade = {
|
||||
depName: 'bazel_skylib',
|
||||
depType: 'http_archive',
|
||||
repo: 'bazelbuild/bazel-skylib',
|
||||
def: `http_archive(
|
||||
name = "bazel_skylib",
|
||||
sha256 = "eb5c57e4c12e68c0c20bc774bfbc60a568e800d025557bc4ea022c6479acc867",
|
||||
strip_prefix = "bazel-skylib-0.6.0",
|
||||
url = "https://github.com/bazelbuild/bazel-skylib/archive/0.6.0.tar.gz",
|
||||
)`,
|
||||
currentValue: '0.6.0',
|
||||
newValue: '0.8.0',
|
||||
};
|
||||
hasha.fromStream.mockReturnValueOnce('abc123');
|
||||
const res = await bazelfile.updateDependency(
|
||||
fileWithBzlExtension,
|
||||
upgrade
|
||||
);
|
||||
expect(res).not.toEqual(fileWithBzlExtension);
|
||||
expect(res.indexOf('0.8.0')).not.toBe(-1);
|
||||
});
|
||||
it('returns null if no urls resolve hashes', async () => {
|
||||
const upgrade = {
|
||||
depName: 'bazel_skylib',
|
||||
|
|
Loading…
Reference in a new issue