Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gitlabci): avoid capturing quotation marks in currentValue #6584

Merged
merged 1 commit into from Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/manager/gitlabci/__fixtures__/gitlab-ci.yaml
@@ -1,3 +1,5 @@
image: 'ruby:2.5.0'

.executor-docker: &executor-docker
tags:
- docker
Expand Down
9 changes: 9 additions & 0 deletions lib/manager/gitlabci/__snapshots__/extract.spec.ts.snap
Expand Up @@ -2,6 +2,15 @@

exports[`lib/manager/gitlabci/extract extractPackageFile() extracts multiple image lines 1`] = `
Array [
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "2.5.0",
"datasource": "docker",
"depName": "ruby",
"depType": "image",
"replaceString": "ruby:2.5.0",
},
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
Expand Down
5 changes: 4 additions & 1 deletion lib/manager/gitlabci/extract.spec.ts
Expand Up @@ -19,7 +19,10 @@ describe('lib/manager/gitlabci/extract', () => {
it('extracts multiple image lines', () => {
const res = extractPackageFile(yamlFile);
expect(res.deps).toMatchSnapshot();
expect(res.deps).toHaveLength(6);
expect(res.deps).toHaveLength(7);
expect(res.deps.some((dep) => dep.currentValue.includes("'"))).toBe(
false
);
});

it('extracts multiple image lines with comments', () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/manager/gitlabci/extract.ts
Expand Up @@ -20,12 +20,12 @@ export function extractPackageFile(content: string): PackageFile | null {
const lines = content.split('\n');
for (let lineNumber = 0; lineNumber < lines.length; lineNumber += 1) {
const line = lines[lineNumber];
const imageMatch = /^\s*image:\s*'?"?([^\s]+|)'?"?\s*$/.exec(line);
const imageMatch = /^\s*image:\s*'?"?([^\s'"]+|)'?"?\s*$/.exec(line);
if (imageMatch) {
switch (imageMatch[1]) {
case '': {
const imageNameLine = skipCommentLines(lines, lineNumber + 1);
const imageNameMatch = /^\s*name:\s*'?"?([^\s]+|)'?"?\s*$/.exec(
const imageNameMatch = /^\s*name:\s*'?"?([^\s'"]+|)'?"?\s*$/.exec(
imageNameLine.line
);

Expand Down