From 8bdf0bcf57622f6ab2831146df9c9d79d9e72a1c Mon Sep 17 00:00:00 2001 From: Andrew Thauer <6507159+andrewthauer@users.noreply.github.com> Date: Wed, 21 Oct 2020 13:34:09 -0400 Subject: [PATCH] fix(catalog-backend): fix codeowners processor to handle users --- .changeset/great-apples-flash.md | 5 +++++ .../src/ingestion/processors/CodeOwnersProcessor.test.ts | 4 ++++ .../src/ingestion/processors/CodeOwnersProcessor.ts | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 .changeset/great-apples-flash.md diff --git a/.changeset/great-apples-flash.md b/.changeset/great-apples-flash.md new file mode 100644 index 0000000000..78ad89dee0 --- /dev/null +++ b/.changeset/great-apples-flash.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Fix CodeOwnersProcessor to handle non team users diff --git a/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.test.ts b/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.test.ts index 622af9ea59..e65714bcfd 100644 --- a/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.test.ts +++ b/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.test.ts @@ -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'); }); diff --git a/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.ts b/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.ts index bc78b6e34a..f186a9425c 100644 --- a/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.ts +++ b/plugins/catalog-backend/src/ingestion/processors/CodeOwnersProcessor.ts @@ -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]; }