add a test for undefined default branch
Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
@@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user