fix(ansible-galaxy): handle git source (#21640)

This commit is contained in:
Rhys Arkins 2023-04-21 11:24:29 +02:00 committed by GitHub
parent 6990f7fc09
commit bf0e39da5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View file

@ -30,7 +30,11 @@ function interpretLine(
}
case 'source': {
localDependency.managerData.source = value;
if (value?.startsWith('git@')) {
localDependency.packageName = value;
} else {
localDependency.registryUrls = value ? [value] : [];
}
break;
}
case 'type': {

View file

@ -38,6 +38,21 @@ describe('modules/manager/ansible-galaxy/extract', () => {
expect(res?.deps[0].currentValue).toBe('1.1.3');
});
it('extracts git@ dependencies', () => {
const yamlFile = codeBlock`collections:
- name: community.docker
source: git@github.com:ansible-collections/community.docker
type: git
version: 2.7.5`;
const res = extractPackageFile(yamlFile, 'requirements.yml');
expect(res?.deps).toHaveLength(1);
expect(res?.deps[0].currentValue).toBe('2.7.5');
expect(res?.deps[0].registryUrls).toBeUndefined();
expect(res?.deps[0].packageName).toBe(
'git@github.com:ansible-collections/community.docker'
);
});
it('check if an empty file returns null', () => {
const res = extractPackageFile('\n', 'requirements.yml');
expect(res).toBeNull();