add a test for undefined default branch

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2021-08-26 22:52:31 +01:00
parent 4d62dc15bb
commit 7ad2b4450a
3 changed files with 15 additions and 6 deletions
@@ -202,6 +202,12 @@ describe('GithubDiscoveryProcessor', () => {
name: 'main',
},
},
{
name: 'techdocs-durp',
url: 'https://github.com/backstage/techdocs-durp',
isArchived: false,
defaultBranchRef: undefined,
},
],
});
const emitter = jest.fn();
@@ -108,15 +108,18 @@ export class GithubDiscoveryProcessor implements CatalogProcessor {
);
for (const repository of matching) {
const branchName = branch === '-' ? repository.defaultBranchRef?.name : branch;
const branchName =
branch === '-' ? repository.defaultBranchRef?.name : branch;
if (!branchName) {
this.logger.info(`the repository ${repository.url} does not have a default branch, skipping`);
this.logger.info(
`the repository ${repository.url} does not have a default branch, skipping`,
);
continue;
}
const path = `/blob/${branchName}${catalogPath}`;
emit(
results.location(
{
@@ -60,7 +60,7 @@ export type Repository = {
name: string;
url: string;
isArchived: boolean;
defaultBranchRef: {
defaultBranchRef?: {
name: string;
};
};