Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
renovate
Commits
61abc03a
Unverified
Commit
61abc03a
authored
4 years ago
by
Rhys Arkins
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(config): validate packageRules matchUpdateTypes combos (#9649)
parent
6232b654
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/config/__snapshots__/validation.spec.ts.snap
+9
-0
9 additions, 0 deletions
lib/config/__snapshots__/validation.spec.ts.snap
lib/config/validation.spec.ts
+17
-0
17 additions, 0 deletions
lib/config/validation.spec.ts
lib/config/validation.ts
+28
-0
28 additions, 0 deletions
lib/config/validation.ts
with
54 additions
and
0 deletions
lib/config/__snapshots__/validation.spec.ts.snap
+
9
−
0
View file @
61abc03a
...
@@ -164,6 +164,15 @@ Array [
...
@@ -164,6 +164,15 @@ Array [
]
]
`;
`;
exports[`config/validation validateConfig(config) errors if invalid combinations in packageRules 1`] = `
Array [
Object {
"message": "packageRules[0]: packageRules cannot combine both matchUpdateTypes and registryUrls. Rule: {\\"matchUpdateTypes\\":[\\"major\\"],\\"registryUrls\\":[\\"https://registry.npmjs.org\\"]}",
"topic": "Configuration Error",
},
]
`;
exports[`config/validation validateConfig(config) errors if language or manager objects are nested 1`] = `
exports[`config/validation validateConfig(config) errors if language or manager objects are nested 1`] = `
Array [
Array [
Object {
Object {
...
...
This diff is collapsed.
Click to expand it.
lib/config/validation.spec.ts
+
17
−
0
View file @
61abc03a
...
@@ -585,5 +585,22 @@ describe(getName(__filename), () => {
...
@@ -585,5 +585,22 @@ describe(getName(__filename), () => {
expect
(
warnings
).
toMatchSnapshot
();
expect
(
warnings
).
toMatchSnapshot
();
expect
(
errors
).
toHaveLength
(
0
);
expect
(
errors
).
toHaveLength
(
0
);
});
});
it
(
'
errors if invalid combinations in packageRules
'
,
async
()
=>
{
const
config
=
{
packageRules
:
[
{
matchUpdateTypes
:
[
'
major
'
],
registryUrls
:
[
'
https://registry.npmjs.org
'
],
},
],
}
as
any
;
const
{
warnings
,
errors
}
=
await
configValidation
.
validateConfig
(
config
,
true
);
expect
(
warnings
).
toHaveLength
(
0
);
expect
(
errors
).
toHaveLength
(
1
);
expect
(
errors
).
toMatchSnapshot
();
});
});
});
});
});
This diff is collapsed.
Click to expand it.
lib/config/validation.ts
+
28
−
0
View file @
61abc03a
...
@@ -325,6 +325,34 @@ export async function validateConfig(
...
@@ -325,6 +325,34 @@ export async function validateConfig(
message
,
message
,
});
});
}
}
// It's too late to apply any of these options once you already have updates determined
const
preLookupOptions
=
[
'
extractVersion
'
,
'
followTag
'
,
'
ignoreDeps
'
,
'
ignoreUnstable
'
,
'
rangeStrategy
'
,
'
registryUrls
'
,
'
respectLatest
'
,
'
rollbackPrs
'
,
'
separateMajorMinor
'
,
'
separateMinorPatch
'
,
'
separateMultipleMajor
'
,
'
versioning
'
,
];
if
(
is
.
nonEmptyArray
(
resolvedRule
.
matchUpdateTypes
))
{
for
(
const
option
of
preLookupOptions
)
{
if
(
resolvedRule
[
option
]
!==
undefined
)
{
const
message
=
`
${
currentPath
}
[
${
subIndex
}
]: packageRules cannot combine both matchUpdateTypes and
${
option
}
. Rule:
${
JSON
.
stringify
(
packageRule
)}
`
;
errors
.
push
({
topic
:
'
Configuration Error
'
,
message
,
});
}
}
}
}
else
{
}
else
{
errors
.
push
({
errors
.
push
({
topic
:
'
Configuration Error
'
,
topic
:
'
Configuration Error
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment