Skip to content

Commit

Permalink
fix(gitlabci): avoid capturing quotation marks in currentValue (#6584)
Browse files Browse the repository at this point in the history
Closes #6516
  • Loading branch information
rarkins committed Jun 25, 2020
1 parent 14f9270 commit b58b90d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
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

0 comments on commit b58b90d

Please sign in to comment.