Merge pull request #28140 from isabeltomb/update-codeownersprocessor-helper
Update CodeOwnersProcessor helper
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
---
|
||||
|
||||
Updated condition in `resolveCodeOwner` to fix a bug where `normalizeCodeOwner` could potentially be called with an invalid argument causing an error in `CodeOwnersProcessor`
|
||||
@@ -46,6 +46,14 @@ describe('resolveCodeOwner', () => {
|
||||
),
|
||||
).toBe('team-foo');
|
||||
});
|
||||
it('should return undefined if the codeowners file contains no names', () => {
|
||||
expect(
|
||||
resolveCodeOwner(
|
||||
`*`,
|
||||
'https://github.com/acme/repo/tree/docs/catalog-info.yaml',
|
||||
),
|
||||
).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('normalizeCodeOwner', () => {
|
||||
|
||||
@@ -30,7 +30,9 @@ export function resolveCodeOwner(
|
||||
const { filepath } = parseGitUrl(catalogInfoFileUrl);
|
||||
const match = codeowners.matchFile(filepath, codeOwnerEntries);
|
||||
|
||||
return match ? normalizeCodeOwner(match.owners[0]) : undefined;
|
||||
return match?.owners?.length
|
||||
? normalizeCodeOwner(match.owners[0])
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function normalizeCodeOwner(owner: string) {
|
||||
|
||||
Reference in New Issue
Block a user