added utility to remove backstage entity refs from entities
Signed-off-by: Phred <fearphage@gmail.com>
This commit is contained in:
@@ -15,7 +15,12 @@
|
||||
*/
|
||||
|
||||
import { Git, getVoidLogger } from '@backstage/backend-common';
|
||||
import { commitAndPushRepo, initRepoAndPush } from './helpers';
|
||||
import { entityNamePickerValidation } from '@backstage/plugin-scaffolder/src/components/fields/EntityNamePicker';
|
||||
import {
|
||||
commitAndPushRepo,
|
||||
familiarizeEntityName,
|
||||
initRepoAndPush,
|
||||
} from './helpers';
|
||||
|
||||
jest.mock('@backstage/backend-common', () => ({
|
||||
Git: {
|
||||
@@ -301,3 +306,17 @@ describe('commitAndPushRepo', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('familiarizeEntityName', () => {
|
||||
it.each([
|
||||
'user:default/catpants',
|
||||
'group:default/catpants',
|
||||
'user:catpants',
|
||||
'default/catpants',
|
||||
'user:custom/catpants',
|
||||
'group:custom/catpants',
|
||||
'catpants',
|
||||
])('should parse: "%s"', (entityName: string) => {
|
||||
expect(familiarizeEntityName(entityName)).toEqual('catpants');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -296,3 +296,7 @@ export function getGitCommitMessage(
|
||||
? gitCommitMessage
|
||||
: config.getOptionalString('scaffolder.defaultCommitMessage');
|
||||
}
|
||||
|
||||
export function familiarizeEntityName(name: string): string {
|
||||
return name.replace(/^.*[:/]/g, '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user