Fix GitHub catalog entity provider event processing branch matching
Signed-off-by: Stephen Glass <stephen@stephen.glass>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-github': patch
|
||||
---
|
||||
|
||||
Fix GitHub catalog entity provider branch matching on event processing.
|
||||
@@ -961,6 +961,33 @@ describe('GithubEntityProvider', () => {
|
||||
|
||||
expect(entityProviderConnection.refresh).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should fail with incorrect branch matching', async () => {
|
||||
const config = createSingleProviderConfig({
|
||||
providerConfig: {
|
||||
catalogPath: '**/catalog-info.yaml',
|
||||
},
|
||||
});
|
||||
const provider = createProviders(config)[0];
|
||||
|
||||
const entityProviderConnection: EntityProviderConnection = {
|
||||
applyMutation: jest.fn(),
|
||||
refresh: jest.fn(),
|
||||
};
|
||||
await provider.connect(entityProviderConnection);
|
||||
|
||||
const event = createPushEvent({
|
||||
catalogFile: {
|
||||
action: 'added',
|
||||
path: 'folder1/folder2/folder3/catalog-info.yaml',
|
||||
},
|
||||
ref: 'refs/heads/my-main-branch',
|
||||
});
|
||||
|
||||
await provider.onEvent(event);
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('on repository event', () => {
|
||||
|
||||
@@ -343,7 +343,7 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber {
|
||||
const branch =
|
||||
this.config.filters.branch || event.repository.default_branch;
|
||||
|
||||
if (!event.ref.includes(branch)) {
|
||||
if (event.ref !== `refs/heads/${branch}`) {
|
||||
this.logger.debug(`skipping push event from ref ${event.ref}`);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user