Skip to content

Commit

Permalink
fix(ansible-galaxy): handle quoted dependencies (#25760)
Browse files Browse the repository at this point in the history
  • Loading branch information
nejch committed Nov 14, 2023
1 parent 8401943 commit 2d356c4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/modules/manager/ansible-galaxy/__fixtures__/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ dependencies:
community.general: 7.3.0
community.general_with_comment: 7.3.0 # This is a comment
community.windows: '>=1.0.0,<2.0.0'
"community.general_quoted": 7.3.0
"community.general_with_comment_quoted": 7.3.0 # This is a comment
"community.windows_quoted": '>=1.0.0,<2.0.0'
repository: "https://github.com/foo/bar"
issues: "https://github.com/foo/bar/issues"
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@ exports[`modules/manager/ansible-galaxy/extract extractPackageFile() check galax
"depName": "community.windows",
"depType": "galaxy-collection",
},
{
"currentValue": "7.3.0",
"datasource": "galaxy-collection",
"depName": "community.general_quoted",
"depType": "galaxy-collection",
},
{
"currentValue": "7.3.0",
"datasource": "galaxy-collection",
"depName": "community.general_with_comment_quoted",
"depType": "galaxy-collection",
},
{
"currentValue": ">=1.0.0,<2.0.0",
"datasource": "galaxy-collection",
"depName": "community.windows_quoted",
"depType": "galaxy-collection",
},
]
`;

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/ansible-galaxy/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('modules/manager/ansible-galaxy/extract', () => {
it('check galaxy definition file', () => {
const res = extractPackageFile(galaxy, 'galaxy.yml');
expect(res?.deps).toMatchSnapshot();
expect(res?.deps).toHaveLength(7);
expect(res?.deps).toHaveLength(10);
});
});

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/ansible-galaxy/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const blockLineRegEx = /^\s*((\w+):\s*(\S+))\s*$/;
export const galaxyDepRegex = /[\w-]+\.[\w-]+/;
export const dependencyRegex = /^dependencies:/;
export const galaxyRegEx = regEx(
/^\s+(?<packageName>[\w.]+):\s*["']?(?<version>.+?)["']?\s*(\s#.*)?$/,
/^\s+["']?(?<packageName>[\w.]+)["']?:\s*["']?(?<version>.+?)["']?\s*(\s#.*)?$/,
);
export const nameMatchRegex = regEx(
/(?<source>((git\+)?(?:(git|ssh|https?):\/\/)?(.*@)?(?<hostname>[\w.-]+)(?:(:\d+)?\/|:))(?<depName>[\w./-]+)(?:\.git)?)(,(?<version>[\w.]*))?/,
Expand Down

0 comments on commit 2d356c4

Please sign in to comment.