fix(catalog-backend): fix codeowners processor to handle users

This commit is contained in:
Andrew Thauer
2020-10-21 13:34:09 -04:00
parent cea1fa92d8
commit 8bdf0bcf57
3 changed files with 11 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Fix CodeOwnersProcessor to handle non team users
@@ -123,6 +123,10 @@ describe('CodeOwnersProcessor', () => {
});
describe('normalizeCodeOwner', () => {
it('should remove the @ symbol', () => {
expect(normalizeCodeOwner('@yoda')).toBe('yoda');
});
it('should remove org from org/team format', () => {
expect(normalizeCodeOwner('@acme/foo')).toBe('foo');
});
@@ -127,6 +127,8 @@ export function findPrimaryCodeOwner(
export function normalizeCodeOwner(owner: string) {
if (owner.match(/^@.*\/.*/)) {
return owner.split('/')[1];
} else if (owner.match(/^@.*/)) {
return owner.substring(1);
} else if (owner.match(/^.*@.*\..*$/)) {
return owner.split('@')[0];
}