Skip to content
Snippets Groups Projects
Unverified Commit 60968093 authored by Michael Kriese's avatar Michael Kriese Committed by GitHub
Browse files

fix(manager:regex): allow no match in combination (#11386)

parent 2f826677
No related branches found
No related tags found
No related merge requests found
......@@ -240,6 +240,20 @@ describe('manager/regex/index', () => {
expect(res.deps).toHaveLength(1);
});
it('extracts with combination strategy and empty file', async () => {
const config: CustomExtractConfig = {
matchStringsStrategy: 'combination',
matchStrings: [
'CHART_REPOSITORY_URL: "(?<registryUrl>.*)\\/(?<depName>[a-z]+)\\/"',
'CHART_VERSION: (?<currentValue>.*?)\n',
],
datasourceTemplate: 'helm',
depNameTemplate: 'helm_repo/{{{ depName }}}',
};
const res = await extractPackageFile('', '.gitlab-ci.yml', config);
expect(res).toBeNull();
});
it('extracts with recursive strategy and single match', async () => {
const config: CustomExtractConfig = {
matchStrings: [
......
......@@ -147,12 +147,17 @@ function handleCombination(
.map((matchString) => regEx(matchString, 'g'))
.flatMap((regex) => regexMatchAll(regex, content)); // match all regex to content, get all matches, reduce to single array
if (!matches.length) {
return [];
}
const combinedGroup = matches
.map((match) => match.groups)
.reduce((mergedGroup, currentGroup) =>
mergeGroups(mergedGroup, currentGroup)
);
// TODO: this seems to be buggy behavior, needs to be checked #11387
const dep = matches
.map((match) => createDependency(match, combinedGroup, config))
.reduce(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment