Merge pull request #3026 from andrewthauer/fix-user-codeowner

fix(catalog-backend): fix codeowners processor to handle users
This commit is contained in:
Fredrik Adelöw
2020-10-21 20:10:11 +02:00
committed by GitHub
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];
}